Skip to content

Commit 97445e8

Browse files
fix api compatibility issue
1 parent 1b70523 commit 97445e8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Season2/1 Word2Vec/word2vec_tf.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,12 @@ def generate_batch(batch_size, num_skips, skip_window):
183183
similarity = tf.matmul(valid_embeddings, normalized_embeddings, transpose_b=True)
184184

185185
# Add variable initializer.
186-
init = tf.global_variables_initializer()
186+
tf_major_ver = int(tf.__version__.split(".")[0])
187+
tf_minor_ver = int(tf.__version__.split(".")[1])
188+
if(tf_major_ver==0 and tf_minor_ver<12):
189+
init = tf.initialize_all_variables()
190+
else:
191+
init = tf.global_variables_initializer()
187192

188193
# Step 5: Begin training.
189194
num_steps = 100001

0 commit comments

Comments
 (0)