Keras: TypeError: fit() got an unexpected keyword argument 'nb_epoch'

Created on 24 Jun 2020  路  4Comments  路  Source: keras-team/keras

I'm training the model using fit with parameter nb_epoch. However, it shows the error:
`---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in
1 #fit model
----> 2 model.fit(X_train, Y_train, batch_size=32, nb_epoch=10, verbose=1)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py in _method_wrapper(self, args, *kwargs)
64 def _method_wrapper(self, args, *kwargs):
65 if not self._in_multi_worker_mode(): # pylint: disable=protected-access
---> 66 return method(self, args, *kwargs)
67
68 # Running inside run_distribute_coordinator already.

TypeError: fit() got an unexpected keyword argument 'nb_epoch'`
I wanna know how to fix it?

tensorflow

Most helpful comment

It's just epochs now. nb_epoch was deprecated years ago.

All 4 comments

It's just epochs now. nb_epoch was deprecated years ago.

It's just epochs now. nb_epoch was deprecated years ago.

Thanks for your help. But when I used epochs , I got another error:

`Epoch 1/10

InvalidArgumentError Traceback (most recent call last)
in
1 #fit model
----> 2 model.fit(X_train, Y_train, batch_size=32, epochs=10, verbose=1)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py in _method_wrapper(self, args, *kwargs)
64 def _method_wrapper(self, args, *kwargs):
65 if not self._in_multi_worker_mode(): # pylint: disable=protected-access
---> 66 return method(self, args, *kwargs)
67
68 # Running inside run_distribute_coordinator already.

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/keras/engine/training.py in 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)
846 batch_size=batch_size):
847 callbacks.on_train_batch_begin(step)
--> 848 tmp_logs = train_function(iterator)
849 # Catch OutOfRangeError for Datasets of unknown size.
850 # This blocks until the batch has finished executing.

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py in __call__(self, args, *kwds)
578 xla_context.Exit()
579 else:
--> 580 result = self._call(args, *kwds)
581
582 if tracing_count == self._get_tracing_count():

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/eager/def_function.py in _call(self, args, *kwds)
609 # In this case we have created variables on the first call, so we run the
610 # defunned version which is guaranteed to never create variables.
--> 611 return self._stateless_fn(args, *kwds) # pylint: disable=not-callable
612 elif self._stateful_fn is not None:
613 # Release the lock early so that multiple threads can perform the call

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/eager/function.py in __call__(self, args, *kwargs)
2418 with self._lock:
2419 graph_function, args, kwargs = self._maybe_define_function(args, kwargs)
-> 2420 return graph_function._filtered_call(args, kwargs) # pylint: disable=protected-access
2421
2422 @property

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/eager/function.py in _filtered_call(self, args, kwargs)
1663 if isinstance(t, (ops.Tensor,
1664 resource_variable_ops.BaseResourceVariable))),
-> 1665 self.captured_inputs)
1666
1667 def _call_flat(self, args, captured_inputs, cancellation_manager=None):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/eager/function.py in _call_flat(self, args, captured_inputs, cancellation_manager)
1744 # No tape is watching; skip to running the function.
1745 return self._build_call_outputs(self._inference_function.call(
-> 1746 ctx, args, cancellation_manager=cancellation_manager))
1747 forward_backward = self._select_forward_and_backward_functions(
1748 args,

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/eager/function.py in call(self, ctx, args, cancellation_manager)
596 inputs=args,
597 attrs=attrs,
--> 598 ctx=ctx)
599 else:
600 outputs = execute.execute_with_cancellation(

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tensorflow/python/eager/execute.py in quick_execute(op_name, num_outputs, inputs, attrs, ctx, name)
58 ctx.ensure_initialized()
59 tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
---> 60 inputs, attrs, num_outputs)
61 except core._NotOkStatusException as e:
62 if name is not None:

InvalidArgumentError: Conv2DCustomBackpropFilterOp only supports NHWC.
[[node gradient_tape/sequential_5/conv2d_8/Conv2DBackpropFilter (defined at :2) ]] [Op:__inference_train_function_2109]

Function call stack:
train_function`
Is this question related to the version of my laptop or python?
I'm using macOS 10.13.6, Python 3.6.4, tensorflow 2.2.0.

please check your code very well, 'epochs' work for me.

please check your code very well, 'epochs' work for me.

InvalidArgumentError: Default MaxPoolingOp only supports NHWC on device type CPU

Getting this error when epochs is used .

Was this page helpful?
0 / 5 - 0 ratings