[英]Error using CSVLogger: 'utf-8' codec can't decode byte 0x92 in position 144: invalid start byte
I'm trying to use CSVLogger in my Network training, but I have the following error at the end of my epoch我正在尝试在我的网络培训中使用 CSVLogger,但在我的时代结束时出现以下错误
2022-06-05 12:55:34 - ERROR - 'utf-8' codec can't decode byte 0x92 in position 144: invalid start byte Traceback (most recent call last):
2022-06-05 12:55:34 - 错误 - 'utf-8' 编解码器无法解码位置 144 中的字节 0x92:无效的起始字节回溯(最近一次调用最后一次):
File "D:\Users\Username\project\simulations\trainer.py", line 188, in train_network history = compile_and_fit(文件“D:\Users\Username\project\simulations\trainer.py”,第 188 行,train_network history = compile_and_fit(
File "D:\Users\Username\project\neural\neural_utils.py", line 77, in compile_and_fit history = model.fit(文件“D:\Users\Username\project\neural\neural_utils.py”,第 77 行,compile_and_fit history = model.fit(
File "D:\Users\Username\project\venv\lib\site-packages\keras\utils\traceback_utils.py", line 67, in error_handler raise e.with_traceback(filtered_tb) from Noneerror_handler 中的文件“D:\Users\Username\project\venv\lib\site-packages\keras\utils\traceback_utils.py”,第 67 行,从 None 提升 e.with_traceback(filtered_tb)
File "C:\Python39\lib\csv.py", line 143, in writeheader return self.writerow(header) File "C:\Python39\lib\csv.py", line 154, in writerow return self.writer.writerow(self._dict_to_list(rowdict))文件“C:\Python39\lib\csv.py”,第 143 行,在 writeheader 中返回 self.writerow(header) 文件“C:\Python39\lib\csv.py”,第 154 行,在 writerow 中返回 self.writer。 writerow(self._dict_to_list(rowdict))
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 144: invalid start byte
UnicodeDecodeError:“utf-8”编解码器无法解码位置 144 中的字节 0x92:无效的起始字节
These are my system information:这些是我的系统信息:
This is my implementation :这是我的实现:
early_stopping = tf.keras.callbacks.EarlyStopping(
monitor='val_loss',
patience=5,
mode='min',
restore_best_weights=True
)
csv_logger = tf.keras.callbacks.CSVLogger(
Path(output_files_directory, 'training.csv'),
separator=',',
append=False
)
model.compile(
loss=tf.losses.MeanSquaredError(),
optimizer=tf.optimizers.SGD(nesterov=True),
metrics=[tf.metrics.MeanSquaredError(), tf.metrics.Accuracy()]
)
# Print model summary
print('Model summary: ')
model.summary()
history = model.fit(
window.train, epochs=nb_epochs,
validation_data=window.val,
callbacks=[
early_stopping,
cp_callback,
csv_logger
]
)
Note that the output path contains spaces (I cannot change the output path, it's fixed by a previous script).请注意,输出路径包含空格(我无法更改输出路径,它已由先前的脚本修复)。 For example in the previous script
output_files_directory
is equal to D:\trained_data\output\16 bits - Original - 1.25MHz\LSTM_32
例如在前面的脚本中
output_files_directory
等于D:\trained_data\output\16 bits - Original - 1.25MHz\LSTM_32
Ok so I figured out what was the issue: The output directory didn't exist.好的,所以我弄清楚了问题所在:输出目录不存在。
It seems that callbacks like tf.keras.callbacks.ModelCheckpoint create the output directory if it doesn't exist, but not tf.keras.callbacks.CSVLogger似乎像 tf.keras.callbacks.ModelCheckpoint 这样的回调会创建输出目录(如果它不存在),而不是 tf.keras.callbacks.CSVLogger
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.