pythontensorflowtensorflow-slim

Tensorflow slim resnet_v2() got an unexpected keyword argument 'spatial_squeeze'


I am working on Tensorflow Slim Resnet_v2 model. My tensorflow version is (1.4.0) and python version is (3.5.4). I am doing an image classification with 2 labels as the output. I am using the tensorflow Slim resnet_v2 model for this classification. When I try to run the following code

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

I am getting the below error.

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'

I cross-checked, the tensorflow slim source code (https://github.com/tensorflow/models/blob/master/research/slim/nets/resnet_v2.py) and line number 159 states that spatial_squeeze is available. I don't why I am not able to use the argument. Could this be the because of the tensorflow version? If so, please let me know which version should I use.


Solution

  • Please import the library directly by pasting the Resnet code directly into your system or fork the TF slim library.