Skip to content

Commit b418e9d

Browse files
Merge pull request CreatCodeBuild#37 from TITAN-PyCompat/tf_compatibility
fix tf api compatibility issue
2 parents 1b70523 + 97445e8 commit b418e9d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Season2/1 Word2Vec/word2vec_tf.py

+6-1
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)