dmonterom / face_recognition_TF2

Training a face Recognizer using ResNet50 + ArcFace in TensorFlow 2.0
48 stars 11 forks source link

ValueError: `colocate_vars_with` must only be passed a variable created in this tf.distribute.Strategy.scope() #4

Open XJX777 opened 4 years ago

XJX777 commented 4 years ago

您好,我在使用您arcface tf2.0版本完成了tfrecord的转换,在使用train_mutigpus训练的时候出现了报错,错误如下: train_multigpu.py:92 train_step step_fn, args=(_images, _labels, _regCoef,)) train_multigpu.py:87 step_fn zip(gradients, model.trainable_variables)) ValueError: colocate_vars_with must only be passed a variable created in this tf.distribute.Strategy.scope(), not: <tf.Variable 'train_model/arcfacelayer/kernel:0' shape=(512, 85742) dtype=float32, numpy=array......................................................................., dtype=float32)> 请问您知道这是什么问题吗?我目前查下来不知道怎样去解决,感谢您的分享!

XJX777 commented 4 years ago

train_multigpu.py:87 step_fn zip(gradients, model.trainable_variables)) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/optimizer_v2/optimizer_v2.py:435 apply_gradients self._create_slots(var_list) /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/optimizer_v2/gradient_descent.py:99 _create_slots self.add_slot(var, "momentum") /usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/optimizer_v2/optimizer_v2.py:573 add_slot with strategy.extended.colocate_vars_with(var): /usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/distribute_lib.py:1341 colocate_vars_with self._validate_colocate_with_variable(colocate_with_variable) /usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/parameter_server_strategy.py:283 _validate_colocate_with_variable values.validate_colocate(colocate_with_variable, self) /usr/local/lib/python3.6/dist-packages/tensorflow/python/distribute/values.py:737 validate_colocate "tf.distribute.Strategy.scope(), not: %r" % (v,))

ValueError: `colocate_vars_with` must only be passed a variable created in this tf.distribute.Strategy.scope(), not: <tf.Variable 'train_model/arcfacelayer/kernel:0' shape=(512, 85742) dtype=float32, numpy=
MohadesehKermany commented 3 years ago

I got the same error. Did you solve it