ValueError: Weights for model sequential_1 have not yet been created. Weights are created when the Model is first called on inputs or `build()` is called with an `input_shape`.
ValueError: Weights for model sequential_1 have not yet been created. Weights are created when the Model is first called on inputs or build()
is called with an input_shape
.
它说模型没创建权重,权重是模型首次调用的时候创建的。
报错的是这句:
self.target_model.set_weights(self.model.get_weights())
target_model()因为没调用过,没有初始权重,直接set_weights()其他模型的权重也不行。
所以在set_weights之前给target_model调用一下:
a_1 = np.argmax(self.target_model.predict(state))
就可以运行了