0
votes

I'm going over the Book Deep Learning with Python from F. Chollet. https://www.manning.com/books/deep-learning-with-python

I'm trying to follow along with the code examples. I just installed keras, and I am getting this error when trying to run this: from this notebook: https://github.com/fchollet/deep-learning-with-python-notebooks/blob/master/2.1-a-first-look-at-a-neural-network.ipynb

from keras import models
from keras import layers

network = models.Sequential()
network.add(layers.Dense(512, activation='relu', input_shape=(28 * 28,)))
network.add(layers.Dense(10, activation='softmax'))

TypeError Traceback (most recent call last) in () 4 network = models.Sequential() 5 network.add(layers.Dense(512, activation='relu', input_shape=(28 * 28,))) ----> 6 network.add(layers.Dense(10, activation='softmax'))

~/anaconda3/lib/python3.6/site-packages/keras/engine/sequential.py in add(self, layer) 179 self.inputs = network.get_source_inputs(self.outputs[0]) 180 elif self.outputs: --> 181 output_tensor = layer(self.outputs[0]) 182 if isinstance(output_tensor, list): 183 raise TypeError('All layers in a Sequential model '

~/anaconda3/lib/python3.6/site-packages/keras/engine/base_layer.py in call(self, inputs, **kwargs) 455 # Actually call the layer, 456 # collecting output(s), mask(s), and shape(s). --> 457 output = self.call(inputs, **kwargs) 458 output_mask = self.compute_mask(inputs, previous_mask) 459

~/anaconda3/lib/python3.6/site-packages/keras/layers/core.py in call(self, inputs) 881 output = K.bias_add(output, self.bias, data_format='channels_last') 882 if self.activation is not None: --> 883 output = self.activation(output) 884 return output 885

~/anaconda3/lib/python3.6/site-packages/keras/activations.py in softmax(x, axis) 29 raise ValueError('Cannot apply softmax to a tensor that is 1D') 30 elif ndim == 2: ---> 31 return K.softmax(x) 32 elif ndim > 2: 33 e = K.exp(x - K.max(x, axis=axis, keepdims=True))

~/anaconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py in softmax(x, axis) 3229 A tensor. 3230 """ -> 3231 return tf.nn.softmax(x, axis=axis) 3232 3233

TypeError: softmax() got an unexpected keyword argument 'axis'

I'm wondering if there's something off with my installation?

keras.__version__
2.2.4

If anyone could give me a clue of what to look into.

1

1 Answers

1
votes

Seems like you have an incompatible Tensorflow version (which Keras is using as a backend). For details look here