I want to use the Model.predict() function in a loop over the training batches. To divide the train_data into batches I use the Dataset class and the batch function:
@tf.function
def training(modell, train_data, batch_size):
train_dataset = tf.data.Dataset.from_tensor_slices(train_data)
train_dataset = train_dataset.shuffle(buffer_size=1024).batch(parameters['batch_size'])
iterator = tf.compat.v1.data.make_initializable_iterator(train_dataset)
for step in range(4):
with tf.GradientTape() as tape:
modell.predict(iterator.get_next(), steps=1)
training(model, train, 400)
but when running the code, I get this error:
file.py:36 training * modell.predict(iterator.get_next(), steps=1) ValueError: When feeding symbolic tensors to a model, we expect the tensors to have a static batch size. Got tensor with shape: (None, 2, 48, 48, 1)
I have looked into other posts but I could not find any solution.
Thanks