简体   繁体   English

使用 CSVLogger 时出错:“utf-8”编解码器无法解码位置 144 中的字节 0x92:起始字节无效

[英]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 None error_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:这些是我的系统信息:

  • System : Windows 11系统:Windows 11
  • Tensorflow version : 2.9.1张量流版本:2.9.1
  • Python version : 3.9 Python版本:3.9

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.

相关问题 UnicodeDecodeError'utf-8'编解码器无法解码位置2893中的字节0x92:无效的起始字节 - UnicodeDecodeError 'utf-8' codec can't decode byte 0x92 in position 2893: invalid start byte “utf-8”编解码器无法解码 position 107 中的字节 0x92:无效的起始字节 - 'utf-8' codec can't decode byte 0x92 in position 107: invalid start byte “utf-8”编解码器无法解码位置 11 中的字节 0x92:起始字节无效 - 'utf-8' codec can't decode byte 0x92 in position 11: invalid start byte “utf-8”编解码器无法解码 position 18 中的字节 0x92:无效的起始字节 - 'utf-8' codec can't decode byte 0x92 in position 18: invalid start byte 我不断收到 UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 1: invalid start byte - I keep getting UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 1: invalid start byte UnicodeDecodeError:“ utf8”编解码器无法解码位置661中的字节0x92:无效的起始字节 - UnicodeDecodeError: 'utf8' codec can't decode byte 0x92 in position 661: invalid start byte Python错误:“ utf8”编解码器无法解码位置85的字节0x92:无效的起始字节 - Python error: 'utf8' codec can't decode byte 0x92 in position 85: invalid start byte Anaconda:UnicodeDecodeError:'utf8'编解码器无法解码位置1412中的字节0x92:无效的起始字节 - Anaconda: UnicodeDecodeError: 'utf8' codec can't decode byte 0x92 in position 1412: invalid start byte 在Windows上使用python错误:UnicodeDecodeError:'utf-8'编解码器无法解码位置110的字节0x80:无效的起始字节 - using python on windows error: UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 110: invalid start byte UnicodeDecodeError:'utf-8'编解码器无法解码位置0的字节0x80:无效的起始字节 - UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM