fchollet / deep-learning-with-python-notebooks

Jupyter notebooks for the code samples of the book "Deep Learning with Python"
MIT License
18.17k stars 8.53k forks source link

Error with 2.1 #115

Open jkylearmstrong opened 5 years ago

jkylearmstrong commented 5 years ago

Following along with the example in 2.1 when I run

network <- keras_model_sequential() %>% 
  layer_dense(units = 512, activation = "relu", input_shape = c(28 * 28)) %>% 
  layer_dense(units = 10, activation = "softmax")

I get the following error:

Error in py_call_impl(callable, dots$args, dots$keywords) : 
  AttributeError: 'Sequential' object has no attribute 'get_shape'

Detailed traceback: 
  File "/home/cdsw/.local/lib/python2.7/site-packages/tensorflow/python/keras/_impl/keras/engine/base_layer.py", line 239, in __call__
    output = super(Layer, self).__call__(inputs, **kwargs)
  File "/home/cdsw/.local/lib/python2.7/site-packages/tensorflow/python/layers/base.py", line 689, in __call__
    self._assert_input_compatibility(inputs)
  File "/home/cdsw/.local/lib/python2.7/site-packages/tensorflow/python/layers/base.py", line 1183, in _assert_input_compatibility
    if x.get_shape().ndims is None:
RorisangSitoboli commented 5 years ago

I had an issue with the second line there but my error was different : 'SyntaxError: positional argument follows keyword argument...'.

I edited the line to: network.add(layers.Dense(512, input_shape=(28*28,), activation='relu')). After this, the code worked without errors. I hope this helps.