tensorflow和keras学习CNN,我试图运行cnn模型来训练mnist数据集,但在我用tnesorflow 2.0升级到2.1之后,我收到了这个错误消息: raise RuntimeError("tf.placeholder() is not compatible with "
RuntimeError: tf.placeholder() is not compatible with eagerexecution.我尝试了下面的代码 tf.compa
, <tensorflow.python.keras.optimizer_v1.SGD object at 0x000002DD585C6680>, ') is not supported when eagerexecution is enabled.Use a `tf.keras` Optimizer instead, or disable eagerexecution.')
有什么想法吗?我做错什么了?
我的情况是,在Colab TPU环境下,节约模式是非常缓慢的。然后,我尝试取出回调并使用model.save_weights()保存模型,但是没有什么改变。通过使用Colab终端,我发现在5分钟内节省的速度约为100 K。我的模特试穿代码在这里:
with tpu_strategy.scope(): # creating the model in the TPUStrategy scope means we will train the model on
keras.models.load_model("/content/gdrive/My Drive/ColabNotebooks/ckpt4/my_model.h5")RuntimeError: tf.placeholder() is not compatible with eagerexecution.