LoginSignup
2
1

More than 5 years have passed since last update.

【tensorflowエラー】Variable hoge already exists, disallowed. Did you mean to set...

Last updated at Posted at 2017-08-30

原因

変数名が被ってる。
chainerだと名前とかつけてなかったから、あまり見なかったエラー。

解決策

1.get_variableで変数名が被らないようにうまく生成する

with tf.variable_scope("my_scope2"):
    v4_init = tf.constant_initializer([4.])
    v4 = tf.get_variable("var4", shape=[1], initializer=v4_init)

print(v4.name)  # my_scope2/var4:0

http://qiita.com/TomokIshii/items/ffe999b3e1a506c396c8
https://deepage.net/tensorflow/2017/06/02/tensorflow-variable.html

2.tf.reset_default_graph()で初期化。

jupyterなどで該当の行を2回目実行してる場合は初期化をすると通る。
あるいはjupyter再起動。
https://github.com/kratzert/finetune_alexnet_with_tensorflow/issues/8

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1