nfmcclure / tensorflow_cookbook

Code for Tensorflow Machine Learning Cookbook

Home Page:https://www.packtpub.com/big-data-and-business-intelligence/tensorflow-machine-learning-cookbook-second-edition

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

07_sentiment_with_doc2vec + skip_gram + tf 1.4.0 = error

ave19 opened this issue · comments

I think the order of parameters probably moved around in tf. But here's what I get:

    batch_inputs, batch_labels = text_helpers.generate_batch_data(
        text_data, batch_size,
        window_size, method='skip_gram')

...errors out with...

Starting Training

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-9-69e5ea759480> in <module>()
     13 
     14     # Run the train step
---> 15     sess.run(train_step, feed_dict=feed_dict)
     16 
     17     # Return the loss

~/env/3.5/lib/python3.5/site-packages/tensorflow/python/client/session.py in run(self, fetches, feed_dict, options, run_metadata)
    887     try:
    888       result = self._run(None, fetches, feed_dict, options_ptr,
--> 889                          run_metadata_ptr)
    890       if run_metadata:
    891         proto_data = tf_session.TF_GetBuffer(run_metadata_ptr)

~/env/3.5/lib/python3.5/site-packages/tensorflow/python/client/session.py in _run(self, handle, fetches, feed_dict, options, run_metadata)
   1094                 'Cannot feed value of shape %r for Tensor %r, '
   1095                 'which has shape %r'
-> 1096                 % (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
   1097           if not self.graph.is_feedable(subfeed_t):
   1098             raise ValueError('Tensor %s may not be fed.' % subfeed_t)

ValueError: Cannot feed value of shape (500,) for Tensor 'Placeholder:0', which has shape '(?, 4)'

I don't have a fix, sorry.

commented

Ah yes, thanks for bringing this to my attention. I think this is a quick fix with the parameters. I'm starting a book/code v2 over the next few months. Expect this to be fixed some time soon. Thanks!

commented

This should be fixed. Please repull and try again with the updated code. Let me know / reopen if you still have issues.