"ValueError: Model <TronModel.TM object at 0x10ef41d90> cannot be saved because the input shapes have not been set. Usually, input shapes are automatically determined from calling .fit() or .predict(). To manually set the shapes, call model.build(input_shape)."
I subclass like so:
class RM(tf.keras.Model):
and call super in my init.
The class trains on a reinforcement learning problem. My call function is very simple. It is just two stacked Dense layers and the state I input is size 2901.
I am having a lot of trouble saving the model however. I tried model.save but that didn't work because I never used model.fit or model.predict. I have defined my own call function, and it's unclear to me how I would use these layers.
I tried putting my layers into a Sequential, calling predict on that in my call function and then saving only that but then there was an issue with the gradients and still the Sequential part of model would not save.
In the error it suggested that I try model.build before saving. Model.build is supposed to define the size of the inputs.
I have tried model.build and it does not solve my problem.
I am really at a loss at this point. This is a reinforcement learning model using the actor critic architecture so there are other parts to it's learning that I would like to save ideally. The critic network is the biggest such part. However, I would just be satisfied saving the weights of the two Dense Layers that take in a state and output a probability distribution over the actions.
Am I using tf.keras.Model in a fundamentally incorrect way?