3

According to the Keras docs, fit takes a validation_freq param:

validation_freq: Only relevant if validation data is provided. Integer or list/tuple/set. If an integer, specifies how many training epochs to run before a new validation run is performed, e.g. validation_freq=2 runs validation every 2 epochs. If a list, tuple, or set, specifies the epochs on which to run validation, e.g. validation_freq=[1, 2, 10] runs validation at the end of the 1st, 2nd, and 10th epochs.

result = model.fit( X_train, Y_train, epochs=2000, verbose=1, validation_data=(X_test,Y_test), validation_freq=10) # , validation_split=0.2

This raises:

File "/Users/george/anaconda3/lib/python3.6/site-packages/keras/engine/training.py", line 942, in fit
raise TypeError('Unrecognized keyword arguments: ' + str(kwargs))
TypeError: Unrecognized keyword arguments: {'validation_freq': 10}

Using Keras2.1.6-tf. Has this param been added since?

If so, how to update Keras for Anaconda? I tried:

> conda update keras
Collecting package metadata: done
Solving environment: done

# All requested packages already installed.
B Seven
  • 44,484
  • 66
  • 240
  • 385

1 Answers1

5

The commit that added validation_freq was added after the latest release 2.2.4. See https://github.com/keras-team/keras/commit/a6c8042121371b5873773ca767f28cdf5689d5e4, which was committed 28 days ago, after the latest release which was released last October.

I fixed this by installing from keras' git repo:

pip uninstall keras
pip install git+git://github.com/keras-team/keras.git

Although you're using conda, pip should still work to install packages. You may have to fiddle around with pip installing to the right python, i.e. pip3 install or on windows python -m pip install. Worst comes to worst use conda to install from the source on github.

Primusa
  • 13,136
  • 3
  • 33
  • 53
  • To answer your question, your answer doesn't tell me ***why*** there is a different file downloaded. Is it because the commit was after last release? And what is the last release? Which version are you running? Your answer creates more questions for me. Also, your solution would not work for me. I don't want to build keras. I'm not sure from your answer, but I guess you are building from the tip of master branch...I would not do that either. I also wouldn't build Anaconda from source, unless there is a good reason to do so. However, your answer was useful to validate my symptom. – B Seven Feb 19 '19 at 18:33
  • The zip file you download with pip just doesn't match what's on git; it feels like an arbitrary error on the part of keras. I can't tell you why it's like that but I told you how to fix it. I'm using "build" as a synonym for "install" here, you just have to run the commands and you get the version of keras that's on git which solves the problem outright. What happens in this answer is functionally the same as conda update, except its updating with whats on the master branch. Please at least run the command and see if it fixes your issue. If it persists let me know so I can help further. – Primusa Feb 19 '19 at 19:33
  • Alright see the edit - you were right about it being added after the latest release. To use the parameter though you will either have to install from the master branch (which is above) or wait for the next release. – Primusa Feb 19 '19 at 19:45