Hey I currently ran into an error while training my model. Maybe someone is familiar with this kind of error and can help me.
I start my Training with following code:
history = student_model.fit(dataset = train_set,
epochs = epochs,
verbose = verbose,
validation_data = val_set,
callbacks = [
tf.keras.callbacks.CSVLogger(f"({log_dir}/train.log"),
tf.keras.callbacks.ModelCheckpoint(best_model_weights,
save_best_only = True,
save_weights_only = True),
tf.keras.callbacks.TensorBoard(log_dir=log_dir)
])
So if I ran it i ran into an error which says that evaluate() got an unexpected keyword 'x'. Here you see the Traceback for this error. But I dont quite get what I should do to resolve it.
Epoch 1/10
3/Unknown - 2s 26ms/step - loss: nan - binary_accuracy: 0.2708
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Input In [11], in <cell line: 1>()
----> 1 history = student_model.fit(dataset = train_set,
2 epochs = epochs,
3 verbose = verbose,
4 validation_data = val_set,
5 callbacks = [
6 tf.keras.callbacks.CSVLogger(f"({log_dir}/train.log"),
7 tf.keras.callbacks.ModelCheckpoint(best_model_weights,
8 save_best_only = True,
9 save_weights_only = True),
10 tf.keras.callbacks.TensorBoard(log_dir=log_dir)
11 ])
File ~/project_Bachelor/deep_Knowledge_Tracing/deepkt.py:134, in DKTModel.fit(self, dataset, epochs, verbose, callbacks, validation_data, shuffle, initial_epoch, steps_per_epoch, validation_steps, validation_freq)
64 def fit (self,
65 dataset,
66 epochs = 1,
(...)
73 validation_steps = None,
74 validation_freq = 1):
75 """Trains the model for a fixed number of epochs(iterations on a dataset).
76 Arguments:
77 dataset: A tf.data.dataset. Should return a tuple of '(inputs,(skills,targets))'
(...)
132
133 """
--> 134 return super(DKTModel, self).fit(x=dataset,
135 epochs = epochs,
136 verbose = verbose,
137 callbacks = callbacks,
138 validation_data = validation_data,
139 shuffle = shuffle,
140 initial_epoch = initial_epoch,
141 steps_per_epoch = steps_per_epoch,
142 validation_steps = validation_steps,
143 validation_freq = validation_freq)
File ~/anaconda3/envs/project/lib/python3.9/site-packages/keras/utils/traceback_utils.py:67, in filter_traceback.<locals>.error_handler(*args, **kwargs)
65 except Exception as e: # pylint: disable=broad-except
66 filtered_tb = _process_traceback_frames(e.__traceback__)
---> 67 raise e.with_traceback(filtered_tb) from None
68 finally:
69 del filtered_tb
File ~/anaconda3/envs/project/lib/python3.9/site-packages/keras/engine/training.py:1445, in Model.fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing)
1431 if getattr(self, '_eval_data_handler', None) is None:
1432 self._eval_data_handler = data_adapter.get_data_handler(
1433 x=val_x,
1434 y=val_y,
(...)
1443 model=self,
1444 steps_per_execution=self._steps_per_execution)
-> 1445 val_logs = self.evaluate(
1446 x=val_x,
1447 y=val_y,
1448 sample_weight=val_sample_weight,
1449 batch_size=validation_batch_size or batch_size,
1450 steps=validation_steps,
1451 callbacks=callbacks,
1452 max_queue_size=max_queue_size,
1453 workers=workers,
1454 use_multiprocessing=use_multiprocessing,
1455 return_dict=True,
1456 _use_cached_eval_dataset=True)
1457 val_logs = {'val_' name: val for name, val in val_logs.items()}
1458 epoch_logs.update(val_logs)
TypeError: evaluate() got an unexpected keyword argument 'x'
CodePudding user response:
Update:
After @Djinn's comments I've looked into your GitHub repo. From the error I've seen that you are calling somewhere this function:
-> 1445 val_logs = self.evaluate(
1446 x=val_x,
1447 y=val_y,
1448 sample_weight=val_sample_weight,
1449 batch_size=validation_batch_size or batch_size,
1450 steps=validation_steps,
1451 callbacks=callbacks,
1452 max_queue_size=max_queue_size,
1453 workers=workers,
1454 use_multiprocessing=use_multiprocessing,
1455 return_dict=True,
1456 _use_cached_eval_dataset=True)
But inside the file deepkt.py
where you define the model, you've defined the function like this:
def evaluate(self, dataset, verbose = 1, steps = None, callbacks = None):
...
So when you call self.evaluate
you should use dataset
and not x
and y
like it looks like from your error, or change your custom evaluate
function to have those arguments.
CodePudding user response:
you have code
history = student_model.fit(dataset = train_set, etc
replace with
history = student_model.fit(x = train_set, etc
also ensure verbose is one of 'auto', 0, 1, or 2