老师你好:使用tf1.15训练 src/train_tripletloss.py 报错
来源:9-11 facenet模型训练

qq_小风_17
2020-10-14
环境 :亚马逊的GPU服务器
tf版本:1.15
训练数据CASIA-FaceV5
出现问题
WARNING:tensorflow:
The TensorFlow contrib module will not be included in TensorFlow 2.0.
For more information, please see:
- https://github.com/tensorflow/community/blob/master/rfcs/20180907-contrib-sunset.md
- https://github.com/tensorflow/addons
- https://github.com/tensorflow/io (for I/O related ops)
If you depend on functionality not listed there, please file an issue.
Model directory: /home/wxf/models/facenet/20201014-074514
Log directory: /home/wxf/logs/facenet/20201014-074514
WARNING:tensorflow:From src/train_tripletloss.py:82: The name tf.set_random_seed is deprecated. Please use tf.compat.v1.set_random_seed instead.
WARNING:tensorflow:From src/train_tripletloss.py:86: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.
WARNING:tensorflow:From src/train_tripletloss.py:107: The name tf.read_file is deprecated. Please use tf.io.read_file instead.
WARNING:tensorflow:From src/train_tripletloss.py:113: The name tf.image.resize_image_with_crop_or_pad is deprecated. Please use tf.image.resize_with_crop_or_pad instead.
WARNING:tensorflow:From /home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/ops/image_ops_impl.py:1518: div (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Deprecated in favor of operator or tf.math.divide.
WARNING:tensorflow:From src/train_tripletloss.py:126: batch_join (from tensorflow.python.training.input) is deprecated and will be removed in a future version.
Instructions for updating:
Queue-based input pipelines have been replaced by tf.data
. Use tf.data.Dataset.interleave(...).batch(batch_size)
(or padded_batch(...)
if dynamic_pad=True
).
WARNING:tensorflow:From /home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/training/input.py:735: QueueRunner.init (from tensorflow.python.training.queue_runner_impl) is deprecated and will be removed in a future version.
Instructions for updating:
To construct input pipelines, use the tf.data
module.
WARNING:tensorflow:From /home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/training/input.py:735: add_queue_runner (from tensorflow.python.training.queue_runner_impl) is deprecated and will be removed in a future version.
Instructions for updating:
To construct input pipelines, use the tf.data
module.
WARNING:tensorflow:From /home/wxf/work/facenet/src/models/inception_resnet_v1.py:140: The name tf.GraphKeys is deprecated. Please use tf.compat.v1.GraphKeys instead.
WARNING:tensorflow:From /home/wxf/work/facenet/src/models/inception_resnet_v1.py:172: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.
WARNING:tensorflow:From /home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/contrib/layers/python/layers/layers.py:1057: Layer.apply (from tensorflow.python.keras.engine.base_layer) is deprecated and will be removed in a future version.
Instructions for updating:
Please use layer.__call__
method instead.
Traceback (most recent call last):
File “src/train_tripletloss.py”, line 486, in
main(parse_arguments(sys.argv[1:]))
File “src/train_tripletloss.py”, line 134, in main
File “src/train_tripletloss.py”, line 134, in main
weight_decay=args.weight_decay)
File “/home/wxf/work/facenet/src/models/inception_resnet_v1.py”, line 149, in inference
dropout_keep_prob=keep_probability, bottleneck_layer_size=bottleneck_layer_size, reuse=reuse)
File “/home/wxf/work/facenet/src/models/inception_resnet_v1.py”, line 180, in inception_resnet_v1
scope=‘Conv2d_1a_3x3’)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/contrib/framework/python/ops/arg_scope.py”, line 182, in func_with_args
return func(*args, **current_args)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/contrib/layers/python/layers/layers.py”, line 1159, in convolution2d
conv_dims=2)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/contrib/framework/python/ops/arg_scope.py”, line 182, in func_with_args
return func(*args, **current_args)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/contrib/layers/python/layers/layers.py”, line 1057, in convolution
outputs = layer.apply(inputs)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/util/deprecation.py”, line 324, in new_func
return func(*args, **kwargs)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/base_layer.py”, line 1700, in apply
return self.call(inputs, *args, **kwargs)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/layers/base.py”, line 548, in call
outputs = super(Layer, self).call(inputs, *args, **kwargs)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/base_layer.py”, line 824, in call
self._maybe_build(inputs)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/base_layer.py”, line 2146, in _maybe_build
self.build(input_shapes)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/keras/layers/convolutional.py”, line 165, in build
dtype=self.dtype)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/layers/base.py”, line 461, in add_weight
**kwargs)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/keras/engine/base_layer.py”, line 529, in add_weight
aggregation=aggregation)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/training/tracking/base.py”, line 712, in _add_variable_with_custom_getter
**kwargs_for_getter)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/ops/variable_scope.py”, line 1500, in get_variable
aggregation=aggregation)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/ops/variable_scope.py”, line 1243, in get_variable
aggregation=aggregation)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/ops/variable_scope.py”, line 550, in get_variable
return custom_getter(**custom_getter_kwargs)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/contrib/layers/python/layers/layers.py”, line 1761, in layer_variable_getter
return _model_variable_getter(getter, *args, **kwargs)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/contrib/layers/python/layers/layers.py”, line 1752, in _model_variable_getter
aggregation=aggregation)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/contrib/framework/python/ops/arg_scope.py”, line 182, in func_with_args
return func(*args, **current_args)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/contrib/framework/python/ops/variables.py”, line 351, in model_variable
aggregation=aggregation)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/contrib/framework/python/ops/arg_scope.py”, line 182, in func_with_args
return func(*args, **current_args)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/contrib/framework/python/ops/variables.py”, line 281, in variable
aggregation=aggregation)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/ops/variable_scope.py”, line 519, in _true_getter
aggregation=aggregation)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/ops/variable_scope.py”, line 933, in _get_single_variable
aggregation=aggregation)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/ops/variables.py”, line 258, in call
return cls._variable_v1_call(*args, **kwargs)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/ops/variables.py”, line 219, in _variable_v1_call
shape=shape)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/ops/variables.py”, line 197, in
previous_getter = lambda **kwargs: default_variable_creator(None, **kwargs)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/ops/variable_scope.py”, line 2519, in default_variable_creator
shape=shape)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/ops/variables.py”, line 262, in call
return super(VariableMetaclass, cls).call(*args, **kwargs)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/ops/variables.py”, line 1688, in init
shape=shape)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/ops/variables.py”, line 1818, in _init_from_args
initial_value(), name=“initial_value”, dtype=dtype)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/python/ops/variable_scope.py”, line 905, in
partition_info=partition_info)
File “/home/wxf/.conda/envs/env3.6-tf1.15/lib/python3.6/site-packages/tensorflow_core/contrib/layers/python/layers/initializers.py”, line 120, in _initializer
raise TypeError(‘Cannot create initializer for non-floating point type.’)
TypeError: Cannot create initializer for non-floating point type.
2回答
-
把tf的版本降低到1.14或者1.13看下是否ok,看样子像是一些api有变化导致的问题。
022020-12-28 -
billfu
2021-07-09
可以找到facenet\src\models\inception_resnet_v1.py 內的
return inception_resnet_v1(images, is_training=phase_train, dropout_keep_prob=keep_probability, bottleneck_layer_size=bottleneck_layer_size, reuse=reuse) 將 images 改成 tf.to_float(images)
00
相似问题