"vscode:/vscode.git/clone" did not exist on "74d2a27ff32616d9f6653bccf26f41a0630a946b"
Commit 66900a72 authored by James Hwang's avatar James Hwang
Browse files

Update swivel to TFr1.0

- TF1.0 has breaking changes for tf.concat
- Replace deprecated summary api
- Replace to be deprecated initialize_all_variables
parent e3ad49a5
...@@ -121,8 +121,8 @@ def count_matrix_input(filenames, submatrix_rows, submatrix_cols): ...@@ -121,8 +121,8 @@ def count_matrix_input(filenames, submatrix_rows, submatrix_cols):
sparse_local_col = features['sparse_local_col'].values sparse_local_col = features['sparse_local_col'].values
sparse_count = features['sparse_value'].values sparse_count = features['sparse_value'].values
sparse_indices = tf.concat(1, [tf.expand_dims(sparse_local_row, 1), sparse_indices = tf.concat([tf.expand_dims(sparse_local_row, 1),
tf.expand_dims(sparse_local_col, 1)]) tf.expand_dims(sparse_local_col, 1)], 1)
count = tf.sparse_to_dense(sparse_indices, [submatrix_rows, submatrix_cols], count = tf.sparse_to_dense(sparse_indices, [submatrix_rows, submatrix_cols],
sparse_count) sparse_count)
...@@ -217,8 +217,8 @@ class SwivelModel(object): ...@@ -217,8 +217,8 @@ class SwivelModel(object):
embedding_dim=config.embedding_size, embedding_dim=config.embedding_size,
vocab_size=self.n_cols, vocab_size=self.n_cols,
name='col_embedding') name='col_embedding')
tf.histogram_summary('row_emb', self.row_embedding) tf.summary.histogram('row_emb', self.row_embedding)
tf.histogram_summary('col_emb', self.col_embedding) tf.summary.histogram('col_emb', self.col_embedding)
matrix_log_sum = math.log(np.sum(row_sums) + 1) matrix_log_sum = math.log(np.sum(row_sums) + 1)
row_bias_init = [math.log(x + 1) for x in row_sums] row_bias_init = [math.log(x + 1) for x in row_sums]
...@@ -227,8 +227,8 @@ class SwivelModel(object): ...@@ -227,8 +227,8 @@ class SwivelModel(object):
trainable=config.trainable_bias) trainable=config.trainable_bias)
self.col_bias = tf.Variable(col_bias_init, self.col_bias = tf.Variable(col_bias_init,
trainable=config.trainable_bias) trainable=config.trainable_bias)
tf.histogram_summary('row_bias', self.row_bias) tf.summary.histogram('row_bias', self.row_bias)
tf.histogram_summary('col_bias', self.col_bias) tf.summary.histogram('col_bias', self.col_bias)
# ===== CREATE GRAPH ===== # ===== CREATE GRAPH =====
...@@ -275,9 +275,9 @@ class SwivelModel(object): ...@@ -275,9 +275,9 @@ class SwivelModel(object):
self.loss = l2_loss + sigmoid_loss self.loss = l2_loss + sigmoid_loss
tf.scalar_summary("l2_loss", l2_loss) tf.summary.scalar("l2_loss", l2_loss)
tf.scalar_summary("sigmoid_loss", sigmoid_loss) tf.summary.scalar("sigmoid_loss", sigmoid_loss)
tf.scalar_summary("loss", self.loss) tf.summary.scalar("loss", self.loss)
# Add optimizer. # Add optimizer.
self.global_step = tf.Variable(0, name='global_step') self.global_step = tf.Variable(0, name='global_step')
...@@ -302,7 +302,7 @@ def main(_): ...@@ -302,7 +302,7 @@ def main(_):
sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options)) sess = tf.Session(config=tf.ConfigProto(gpu_options=gpu_options))
# Run the Op to initialize the variables. # Run the Op to initialize the variables.
sess.run(tf.initialize_all_variables()) sess.run(tf.global_variables_initializer())
# Start feeding input # Start feeding input
coord = tf.train.Coordinator() coord = tf.train.Coordinator()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment