关于h5py版本的问题

环境配置上出现了一个非常离谱的问题:
对于我的模型训练和预测代码

# 只是主程序
if __name__ =='__main__':

    train_full_array, img_full_array = training_data_generation(256, 256, 0.5, 0.5)
    PCNN = pcnn_model(256,256,4)
    # 训练模型
    history = PCNN.fit(train_full_array, img_full_array,epochs=50,batch_size=64)
    LSTM_model = 'model.h5'
    PCNN.save(LSTM_model)
    load_model = keras.models.load_model('model.h5')
    image_model_predict(
        'Test_MS/983.png',
        'Test_SAR/983.png',
        'result.png',
        256,
        256,
        load_model,
        0.5
    )

tensorflow=2.6.0
keras=2.6.0
但当我使用h5py=3.1.0以上,也就是3.x版本的时候,可以训练模型但是保存模型时,会报错require h5py的包
但当我降低h5py=2.10版本或以下时,模型又无法开始训练,会报错:

UserWarning: h5py is running against HDF5 1.10.6 when it was built against 1.10.5, this may cause problems
_warn(("h5py is running against HDF5 {0} when it was built against {1}, "
Warning! HDF5 library version mismatched error
The HDF5 header files used to compile this application do not match
the version used by the HDF5 library to which this application is linked.
Data corruption or segmentation faults may occur if the application continues.
This can happen when an application was compiled by one version of HDF5 but
linked with a different version of static or shared HDF5 library.
You should recompile the application or check your shared library related settings such as ‘LD_LIBRARY_PATH’.
You can, at your own risk, disable this warning by setting the environment variable ‘HDF5_DISABLE_VERSION_CHECK’ to a value of ‘1’.
Setting it to 2 or higher will suppress the warning messages totally.
Headers are 1.10.5, library is 1.10.6

查了很多资料,都是说降低或者升级h5py库,但都无法解决我的问题,最后这个链接解决了我的问题:
https://github.com/keras-team/keras/issues/14766
因此,我在保存模型,不要选择.h5文件,而改成:

# 只是主程序
if __name__ =='__main__':

    train_full_array, img_full_array = training_data_generation(256, 256, 0.5, 0.5)
    PCNN = pcnn_model(256,256,4)
    # 训练模型
    history = PCNN.fit(train_full_array, img_full_array,epochs=50,batch_size=64)
    LSTM_model = 'model'
    PCNN.save(LSTM_model)
    load_model = keras.models.load_model('model')
    image_model_predict(
        'Test_MS/983.png',
        'Test_SAR/983.png',
        'result.png',
        256,
        256,
        load_model,
        0.5
    )
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值