Tensorflow slim resnet_v2()得到了一个意外的关键字参数'spatial_squeeze'

问题描述 投票:0回答:1

我正在研究Tensorflow Slim Resnet_v2模型。我的tensorflow版本是(1.4.0),python版本是(3.5.4)。我正在进行图像分类,输出有2个标签。我使用tensorflow Slim resnet_v2模型进行此分类。当我尝试运行以下代码时

predictions,_ = nets.resnet_v2.resnet_v2(x,num_classes=2, is_training=True,
                                      global_pool=True,spatial_squeeze=True)

我收到以下错误。

Traceback (most recent call last):

File "<ipython-input-2-a112bf21d73f>", line 1, in <module>
runfile('D:/Users/apxcm/Mammo_Transfer_learning/inception_fulltrain_azure.py', wdir='D:/Users/apxcm/Mammo_Transfer_learning')

File "D:\Users\apxcm\AppData\Local\Continuum\anaconda3\envs\nnet\lib\site-packages\spyder\utils\site\sitecustomize.py", line 710, in runfile
execfile(filename, namespace)

File "D:\Users\apxcm\AppData\Local\Continuum\anaconda3\envs\nnet\lib\site-packages\spyder\utils\site\sitecustomize.py", line 101, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)

File "D:/Users/apxcm/Mammo_Transfer_learning/inception_fulltrain_azure.py", line 367, in <module>
main()

File "D:/Users/apxcm/Mammo_Transfer_learning/inception_fulltrain_azure.py", line 361, in main
resnet_full_classification()

File "D:/Users/apxcm/Mammo_Transfer_learning/inception_fulltrain_azure.py", line 326, in resnet_full_classification
predictions,_ = nets.resnet_v2.resnet_v2(x,num_classes=2, is_training=True,global_pool=True,spatial_squeeze=True)

TypeError: resnet_v2() got an unexpected keyword argument 'spatial_squeeze'

我交叉检查,tensorflow slim源代码(https://github.com/tensorflow/models/blob/master/research/slim/nets/resnet_v2.py)和行号159表明spatial_squeeze可用。我不知道为什么我不能使用这个论点。这可能是因为tensorflow版本?如果是这样,请告诉我应该使用哪个版本。

python tensorflow tensorflow-slim
1个回答
0
投票

请直接将Resnet代码粘贴到系统中或直接导入TF slim库。

© www.soinside.com 2019 - 2024. All rights reserved.