利用TensorFlow的debug工具tfdbg_ascend生成npy文件。详细的操作方法如下:
样例一:
import tfdbg_ascend as dbg
tfdbg.disable()
if current_step == 5:
tfdbg.enable()
tfdbg.set_dump_path('home/test/gpu_dump')
import tfdbg_ascend as dbg
class DumpConfig(tf.keras.callbacks.Callback):
def __init__(self):
super().__init__()
def on_batch_begin(self, batch, logs={}):
if batch == 4:
dbg.enable()
dbg.set_dump_path("/user/name1/pip_pkg/dump4")
else:
dbg.disable()
# define callbacks
callbacks = [
ModelCheckpoint(
f'models/model_epochs-{epochs}_batch-{batch_size}_loss-{loss_function}_{Mask2FaceModel.get_datetime_string()}.h5'),
LossHistory(batch_size),
DumpConfig()
]
# fit the model 调起模型的代码位置
history = self.model.fit(train_dataset, validation_data=valid_dataset, epochs=1, callbacks=callbacks, verbose=2)