Raspberrypi:Tensorflow:TypeError:意外的关键字参数传递给了优化器:name

时间:2019-06-19 13:46:30

标签: tensorflow raspberry-pi

一个月前我建立了Tensorflow模型,并将其保存为Windows笔记本电脑中的h5文件。将该文件移至Raspberrypi 3后,一切正常。但是,我最近尝试在便携式计算机上使用新的数据集训练模型,并将文件移至Raspberrypi,该模型现在无法加载新的h5文件。

我不确定可能是什么问题(因为我已经完成了一些pip安装和升级),并且当前在笔记本电脑和raspberrypi上都运行Python 3.6。我已经运行了tensorflow的升级以使其今天成为最新版本,即版本2,并试图也运行。相同的保存模型可以在笔记本电脑上正常工作。

以下是保存模型的代码段>>

def train_store_model():
   checkpoint_path = MODELS
   checkpoint_dir = os.path.dirname(checkpoint_path)


   cp_callback = tf.keras.callbacks.ModelCheckpoint(checkpoint_path,
                                                 save_weights_only=True,
                                                 verbose=1)
   model=create_model()
   model.fit(x_train, y_train, epochs=100)
   model.evaluate(x_test, y_test)
   model.save(os.path.join(MODELS,'my_model.h5'))

train_store_model()

trained_model = keras.models.load_model(os.path.join(MODELS,'my_model.h5'))

正在加载相同的内容>>(这是引发问题的地方)

trained_model = keras.models.load_model(os.path.join(MODELS,'my_model.h5'))

以下是在raspberrypi上运行时的错误

pi@raspberrypi:~ $ sudo python3 f_tester_io.py
/usr/local/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: compiletim                                                                   e version 3.4 of module 'tensorflow.python.framework.fast_tensor_util' does not                                                                                         match runtime version 3.6
  return f(*args, **kwds)
/usr/local/lib/python3.6/importlib/_bootstrap.py:219: RuntimeWarning: builtins.t                                                                                        ype size changed, may indicate binary incompatibility. Expected 432, got 412
  return f(*args, **kwds)
WARNING:tensorflow:From /usr/local/lib/python3.6/site-packages/tensorflow/python                                                                                        /ops/resource_variable_ops.py:435: colocate_with (from tensorflow.python.framewo                                                                                        rk.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
Traceback (most recent call last):
  File "fall_tester_io.py", line 31, in <module>
    trained_model = keras.models.load_model(os.path.join(MODELS,'my_model.h5'))
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/keras/engine/sa                                                                                        ving.py", line 249, in load_model
    optimizer_config, custom_objects=custom_objects)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/keras/optimizer                                                                                        s.py", line 838, in deserialize
    printable_module_name='optimizer')
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/keras/utils/gen                                                                                        eric_utils.py", line 194, in deserialize_keras_object
    return cls.from_config(cls_config)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/keras/optimizer                                                                                        s.py", line 159, in from_config
    return cls(**config)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/keras/optimizer                                                                                        s.py", line 247, in __init__
    super(RMSprop, self).__init__(**kwargs)
  File "/usr/local/lib/python3.6/site-packages/tensorflow/python/keras/optimizer                                                                                        s.py", line 68, in __init__`enter code here`
    'passed to optimizer: ' + str(k))
TypeError: Unexpected keyword argument passed to optimizer: name

0 个答案:

没有答案