ageron / handson-ml

⛔️ DEPRECATED – See https://github.com/ageron/handson-ml3 instead.
Apache License 2.0
25.14k stars 12.91k forks source link

Chapter 10, "Using plain tensorflow" does not work #610

Closed HuangLED closed 3 years ago

HuangLED commented 3 years ago

Using google notebook. Simply cope and pasted the example, I got error saying


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-23-48ec64e78376> in <module>()
     65         #    sess.run(training_op, feed_dict={X: X_batch, y: y_batch})
     66         sess.run(training_op, feed_dict={X: X_train, y: y_train})
---> 67         acc_batch = accuracy.eval(feed_dict={X: X_batch, y: y_batch})
     68         acc_val = accuracy.eval(feed_dict={X: X_valid, y: y_valid})
     69         print(epoch, "Batch accuracy:", acc_batch, "Val accuracy:", acc_val)

3 frames
/tensorflow-1.15.2/python3.6/tensorflow_core/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
   1154                 'Cannot feed value of shape %r for Tensor %r, '
   1155                 'which has shape %r' %
-> 1156                 (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
   1157           if not self.graph.is_feedable(subfeed_t):
   1158             raise ValueError('Tensor %s may not be fed.' % subfeed_t)

ValueError: Cannot feed value of shape (50, 28, 28) for Tensor 'X:0', which has shape '(?, 784)'
``

Any suggestion?