Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: fit() got an unexpected keyword argument 'show_accuracy' ---- Graph().fit #2096

Closed
fluency03 opened this issue Mar 27, 2016 · 6 comments

Comments

@fluency03
Copy link

I am training the Graph model with using fit with parameter show_accuracy. However, I got the error:

TypeError: fit() got an unexpected keyword argument 'show_accuracy'

When I check the source code on github here, it shows that Graph's fit has show_accuracy:

def fit(self, data, batch_size=128, nb_epoch=100, verbose=1, callbacks=[],
        validation_split=0., validation_data=None, shuffle=True,
        show_accuracy=False,
        class_weight={}, sample_weight={}):

But when I check the release version 0.3.2, it is like:

def fit(self, data, batch_size=128, nb_epoch=100, verbose=1, callbacks=[],
        validation_split=0., validation_data=None, shuffle=True,
        class_weight={}, sample_weight={}):

I am wondering, which one is the newest version?

I used this pip install git+git://github.com/fchollet/keras.git to install Keras. Even this, the Graph's fit I got has no show_accuracy parameter.

@jisungk
Copy link

jisungk commented Mar 27, 2016

Hi @fluency03,

The Github version is the newer one -- it has some modules which the PyPI version does not have. I checked my version (which was downloaded from Github) and I see the following code:

def fit(self, data, batch_size=128, nb_epoch=100, verbose=1, callbacks=[],
            validation_split=0., validation_data=None, shuffle=True,
            show_accuracy=False,
            class_weight={}, sample_weight={}):

Did you previously install Keras using the command, sudo pip install keras?

If so, maybe you should try upgrading your installation with the following command:
sudo pip install --upgrade git+git://github.com/fchollet/keras.git

@fluency03
Copy link
Author

@jisungk I have done this sudo pip install git+git://github.com/fchollet/keras.git. Is it necessary to add --upgrade?

@jisungk
Copy link

jisungk commented Mar 27, 2016

@fluency03 if you have any previous installation of Keras, then calling sudo pip install.... will not make any updates. You have to specify that you want to upgrade your existing installation with the --upgrade flag.

Hope this helps!

@fluency03
Copy link
Author

@jisungk It's solved. thanks

@KingfaLuis
Copy link

model.fit(X_train, Y_train,
batch_size=128, nb_epoch=4,
show_accuracy=True, verbose=1,
validation_data=(X_test, Y_test))

get the error
TypeError Traceback (most recent call last)
in ()
2 batch_size=128, nb_epoch=4,
3 show_accuracy=True, verbose=1,
----> 4 validation_data=(X_test, Y_test))

/usr/local/lib/python3.6/dist-packages/keras/models.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)
983 epochs = kwargs.pop('nb_epoch')
984 if kwargs:
--> 985 raise TypeError('Unrecognized keyword arguments: ' + str(kwargs))
986
987 if not self.built:

TypeError: Unrecognized keyword arguments: {'show_accuracy': True}

@tsinghuazl22
Copy link

what about the error fit_generator() got an unexpected keyword argument 'samples_per_epoch'?My keras version is 2.4.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants