AttributeError: 'NoneType' 对象没有属性 'evaluate' 评估 keras 中加载的模型

问题描述

# my save model function 
# saving and reloadinng the trained model 
import os 
def save_model(model,suffix = None):
    model_dir = os.path.join('./',datetime.datetime.now().strftime("%Y%m%d%H%M%s"))
    model_path = model_dir + '-' + suffix + '.h5' # save format of the model 
    print('saving model to : ' + model_path + '...')
    model.save(model_path)
    return model_path

加载模型函数:

def load_model(model_path):
    print('loading saved model from ' + model_path)
    model = tf.keras.models.load_model(model_path,custom_objects = {'KerasLayer':hub.KerasLayer},compile=False)

after saving and loading the model there is no error

loaded_1000_image_model.evaluate(val_data)

当我尝试评估加载的模型时,它会说

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-144-1940330b6409> in <module>
----> 1 loaded_1000_image_model.evaluate(val_data)

AttributeError: 'NoneType' object has no attribute 'evaluate'

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)