简体   繁体   中英

Deep learning cannot run model.fit function

I am using the Cifar-10 dataset and I am trying to proceed with transfer learnin by using keras library. My code is here - https://github.com/YanaNeykova/Cifar-10 Upon running line

model.fit(X_train, y_train, batch_size=32, epochs=10,
         verbose=1, callbacks=[checkpointer],validation_split=0.2, shuffle=True)

I get an error ( visible in the file), and therefore I cannot proceed further. I tried it also with importing additionally the model function from keras , but I get again the same result - function model is not recognized. Can someone advise how I can proceed ? Many thanks in advance!

Error

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-11-977cb2a1e5d6> in <module>()
      1 model.fit(X_train, y_train, batch_size=32, epochs=10,
----> 2          verbose=1, callbacks=[checkpointer],validation_split=0.2, shuffle=True)

/usr/local/lib/python3.6/dist-packages/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, **kwargs)
   1008         else:
   1009             ins = x + y + sample_weights
-> 1010         self._make_train_function()
   1011         f = self.train_function
   1012 

/usr/local/lib/python3.6/dist-packages/keras/engine/training.py in _make_train_function(self)
    517                     updates=updates,
    518                     name='train_function',
--> 519                     **self._function_kwargs)
    520 
    521     def _make_test_function(self):

/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py in function(inputs, outputs, updates, **kwargs)
   2742                 msg = 'Invalid argument "%s" passed to K.function with TensorFlow backend' % key
   2743                 raise ValueError(msg)
-> 2744     return Function(inputs, outputs, updates=updates, **kwargs)
   2745 
   2746 

/usr/local/lib/python3.6/dist-packages/keras/backend/tensorflow_backend.py in __init__(self, inputs, outputs, updates, name, **session_kwargs)
   2573             raise ValueError('Some keys in session_kwargs are not '
   2574                              'supported at this '
-> 2575                              'time: %s', session_kwargs.keys())
   2576         self._callable_fn = None
   2577         self._feed_arrays = None

ValueError: ('Some keys in session_kwargs are not supported at this time: %s', dict_keys(['metric']))

You have a typo error, try replaceing metric with metrics

Also you should correct loss binary_crossentropy to caegorical_crossentropy

model.compile(loss='caegorical_crossentropy', optimizer='adam',
         metrics=['accuracy'])

You are using metric keyword argument that seems to be unsupported in the following line:

model.compile(loss='binary_crossentropy', optimizer='adam',
             metric=['accuracy'])

Try to remove it and see if it works. It may be unsupported in your model.

Also, I have noticed that you may have a typo in the name of the loss function loss='caegorical_crossentropy' ... but I guess that is another issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM