variable scope
を参照するTensorFlowウェブサイトの2つのリンクがあり、1つはtf.variable_scopeであり、もう1つはtf.VaribleScopeです。TensorFlow - tf.VariableScopeとtf.variable_scopeの相違点
tf.VariableScope
のアプリケーションの例はありません。ドキュメントを読むだけで、2つの違いがあるかどうかを区別できませんでした。
Traceback (most recent call last):
File "/home/NER/window_model.py", line 105, in <module>
model = NaiveNERModel(embeddings)
File "/home/NER/window_model.py", line 64, in __init__
pred = self.add_prediction_op(embed)
File "/home/NER/window_model.py", line 82, in add_prediction_op
with tf.VariableScope('Layer1', initializer=tf.contrib.layers.xavier_initializer()):
AttributeError: __enter__
(いくつかの違いがそこにいる示している)tf.VariableScope
でtf.variable_scope
を交換することによって実現しようとしましたが、次のエラーを得たオリジナルの実行可能なコードのスニペット
with tf.variable_scope('Layer1', initializer=tf.contrib.layers.xavier_initializer()):
W = tf.get_variable("W", [self.dim * self.window_size, self.dim * self.window_size])
b1 = tf.get_variable("b1", [self.dim * self.window_size])
h = tf.nn.relu(tf.matmul(embed, W) + b1)