deep-learning-with-python-notebooks icon indicating copy to clipboard operation
deep-learning-with-python-notebooks copied to clipboard

Error with 2.1

Open jkylearmstrong opened this issue 5 years ago • 1 comments

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:

jkylearmstrong avatar Jun 13 '19 13:06 jkylearmstrong

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.

RorisangSitoboli avatar Aug 31 '19 09:08 RorisangSitoboli