Skip to content

word2vec_tensorfow; AttributeError: module 'tensorflow' has no attribute 'placeholder' #2

@ziwenyd

Description

@ziwenyd

versions: I am using tensorflow 2; python3

Thank you for the helpful tutorial! I am trying your tutorial code for word2vec but seems there is a version issue.

I searched and found out that seems placeholder is no longer supported in TensorFlow v2, could you please update the tutorial code or share a hint on how to fix it? Thanks!

Error is found at:
word2vec_tensorflow -> Defien Tensorflow Graph
`import tensorflow as tf

making placeholders for X_train and Y_train

x = tf.placeholder(tf.float32, shape=(None, ONE_HOT_DIM))
y_label = tf.placeholder(tf.float32, shape=(None, ONE_HOT_DIM))`

Error message:
`---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in
1 import tensorflow as tf
2 # making placeholders for X_train and Y_train
----> 3 x = tf.placeholder(tf.float32, shape=(None, ONE_HOT_DIM))
4 y_label = tf.placeholder(tf.float32, shape=(None, ONE_HOT_DIM))

AttributeError: module 'tensorflow' has no attribute 'placeholder'`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions