File "/root/Desktop/EAST-master/multigpu_train.py", line 180, in <module> tf.app.run() File "/root/miniconda3/envs/txy2/lib/python3.7/site-packages/tensorflow_core/python/platform/app.py", line 40, in run _run(main=main, argv=argv, flags_parser=_parse_flags_tolerate_undef) File "/root/miniconda3/envs/txy2/lib/python3.7/site-packages/absl/app.py", line 312, in run _run_main(main, args) File "/root/miniconda3/envs/txy2/lib/python3.7/site-packages/absl/app.py", line 258, in _run_main sys.exit(main(argv)) File "/root/Desktop/EAST-master/multigpu_train.py", line 110, in main total_loss, model_loss = tower_loss(iis, isms, igms, itms, reuse_variables) File "/root/Desktop/EAST-master/multigpu_train.py", line 30, in tower_loss f_score, f_geometry = model.model(images, is_training=True) File "/root/Desktop/EAST-master/model.py", line 77, in model spp_output = spp_layer(f[0]) File "/root/Desktop/EAST-master/model.py", line 44, in spp_layer strides=[1, strides[0], strides[1], 1], padding='VALID') File "/root/miniconda3/envs/txy2/lib/python3.7/site-packages/tensorflow_core/python/ops/nn_ops.py", line 3815, in max_pool name=name) File "/root/miniconda3/envs/txy2/lib/python3.7/site-packages/tensorflow_core/python/ops/gen_nn_ops.py", line 5662, in max_pool ksize = [_execute.make_int(_i, "ksize") for _i in ksize] File "/root/miniconda3/envs/txy2/lib/python3.7/site-packages/tensorflow_core/python/ops/gen_nn_ops.py", line 5662, in <listcomp> ksize = [_execute.make_int(_i, "ksize") for _i in ksize] File "/root/miniconda3/envs/txy2/lib/python3.7/site-packages/tensorflow_core/python/eager/execute.py", line 169, in make_int (arg_name, repr(v))) TypeError: Expected int for argument 'ksize' not <tf.Tensor 'model_0/feature_fusion/SpatialPyramidPooling/strided_slice_2:0' shape=() dtype=int32>. Process finished with exit code 1
时间: 2023-09-12 14:06:30 浏览: 238
bert-base-chinese-tf_model.h5
这个错误是由于传递给函数的参数 ksize 需要是整数类型,但是你传递了一个 Tensor 对象。你需要确保将 Tensor 转换为整数类型后再传递给函数。你可以使用 TensorFlow 的 `tf.cast()` 函数将 Tensor 转换为整数类型,例如:`tf.cast(ksize_tensor, tf.int32)`。你需要找到代码中使用了 `tf.nn.max_pool()` 函数的部分,并检查是否在调用该函数时传递了一个 Tensor 类型的 ksize 参数,如果是,则需要将其转换为整数类型。例如,你可以将以下代码:
```
pool = tf.nn.max_pool(input, ksize=ksize_tensor, strides=[1, strides[0], strides[1], 1], padding='VALID')
```
修改为:
```
ksize = tf.cast(ksize_tensor, tf.int32)
pool = tf.nn.max_pool(input, ksize=[1, ksize, ksize, 1], strides=[1, strides[0], strides[1], 1], padding='VALID')
```
这应该可以解决你的问题。
阅读全文