Как я могу передать логическое значение заполнителю при использовании benchmark_model в Tensorflow? - PullRequest
0 голосов
/ 14 сентября 2018

Мои первые два слоя моей модели:

('#', 1, '#', '|Input Tensors {}|:', (<tf.Tensor 'import/Placeholder:0' shape=(5, 360, 480, 3) dtype=float32>,))
('#', 2, '#', '|Input Tensors {}|:', (<tf.Tensor 'import/phase_train:0' shape=<unknown> dtype=bool>,))

Я хочу сравнить модель с помощью инструмента Tensorflow. Я должен установить два параметра (float и bool).

Я использую эталонный инструмент, как этот:

bazel-bin/tensorflow/tools/benchmark/benchmark_model \
--graph=saved_model_fp32.pb \
--input_layer='Placeholder','phase_train' \
--input_layer_shape='5,360,480,3:0' \
--input_layer_type='float','bool' \
--output_layer='conv_decode1/cond/Merge' \
--show_run_order=false --show_time=false \
--show_memory=false --show_summary=false \
--show_flops=true #--logtostderr

но он жалуется на то, как я передаю логическое значение:

2018-09-14 13:37:33.529605: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
2018-09-14 13:37:33.561214: I tensorflow/tools/benchmark/benchmark_model.cc:492] Initialized session in 0.031689s
2018-09-14 13:37:33.561269: I tensorflow/tools/benchmark/benchmark_model.cc:323] Running benchmark for max 1 iterations, max -1 seconds without detailed stat logging, with -1s sleep between inferences
2018-09-14 13:37:33.979259: E tensorflow/tools/benchmark/benchmark_model.cc:302] Error during inference: Invalid argument: The second input must be a scalar, but it has shape [0]
     [[Node: conv1/cond/Switch = Switch[T=DT_BOOL, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_phase_train_0_1, _arg_phase_train_0_1)]]
2018-09-14 13:37:33.979956: I tensorflow/tools/benchmark/benchmark_model.cc:344] Failed on run 0
2018-09-14 13:37:33.979975: E tensorflow/tools/benchmark/benchmark_model.cc:562] Timing failed with Invalid argument: The second input must be a scalar, but it has shape [0]
     [[Node: conv1/cond/Switch = Switch[T=DT_BOOL, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_phase_train_0_1, _arg_phase_train_0_1)]]

Как правильно использовать инструмент для тестирования?

1 Ответ

0 голосов
/ 18 сентября 2018

Похоже, простой способ - определить постоянный тензор с тем же именем tf.constant(False, dtype=bool, shape=[], name='phase_train') и установить его вместо заполнителя phase_train.

Это сработало для меня :)

...