问题描述
在跑代码的时候出现报错提示
Traceback (most recent call last):
File "multi_detect_Nerual.py", line 4, in
import BiLSTM.bilstm_speech_seg_predict as nerual_seg
File "/home/xxx/xxx/xxx/BiLSTM/bilstm_speech_seg_predict.py", line 23, in
model.load_weights(h5_model_file)
File "/home/xxx/anaconda3/envs/xxx/lib/python3.7/site-packages/keras/engine/network.py", line 1166, in load_weights
f, self.layers, reshape=reshape)
File "/home/xxx/anaconda3/envs/xxx/lib/python3.7/site-packages/keras/engine/saving.py", line 1004, in load_weights_from_hdf5_group
original_keras_version = f.attrs['keras_version'].decode('utf8')
AttributeError: 'str' object has no attribute 'decode'
问题分析
该报错意思是:属性错误:'str'对象没有'decode'属性
解决方法
最简单的方法,不用修改代码
pip install 'h5py<3.0.0' -i https://pypi.tuna.tsinghua.edu.cn/simple
如下所示,问题解决!
Colocations handled automatically by placer.
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
bidirectional_1 (Bidirection (None, 200, 256) 167936
_________________________________________________________________
bidirectional_2 (Bidirection (None, 200, 256) 394240
_________________________________________________________________
time_distributed_1 (TimeDist (None, 200, 32) 8224
_________________________________________________________________
time_distributed_2 (TimeDist (None, 200, 32) 1056
_________________________________________________________________
time_distributed_3 (TimeDist (None, 200, 1) 33
=================================================================
Total params: 571,489
Trainable params: 571,489
Non-trainable params: 0
_________________________________________________________________
2022-10-24 15:01:09.369530: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 AVX512F FMA
2022-10-24 15:01:09.391688: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3400000000 Hz
2022-10-24 15:01:09.396757: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x55ba4e0a7330 executing computations on platform Host. Devices:
2022-10-24 15:01:09.396799: I tensorflow/compiler/xla/service/service.cc:158] StreamExecutor device (0): ,
(35, 3841)
(73, 200, 35)
(73, 200, 1)
The segmentation point for this audio file is listed (Unit: /s) [ 5.888 7.248 8.8 11.664 13.056 19.408 21.216 22.896 26.16 28.4
30.928 33.424 40.688 50.512 53.936]