Closed rohith513 closed 4 years ago
Hi There, We are checking to see if you still need help on this, as this seems to be an old issue. Please update this issue with the latest information, code snippet to reproduce your issue and error you are seeing. If we don't hear from you in the next 7 days, this issue will be closed automatically. If you don't need help on this issue any more, please consider closing this.
System information
Describe the problem Hello, I am trying to replace few convolution layers in Resnet50 with Locally Connected layers. As you can see below, I want to replace the middle layer of the bottleneck block with locally connected. This layer uses padding='same'. But locally connected right now supports only padding='valid'. Is there a way to implement this?
or Any other ideas to replace few convolution layers with locally connected layers?
Source code / logs:
From this: runs only when depth==256 or 512 '''residual = slim.conv2d(inputs, depth_bottleneck, [1, 1], stride=1,scope='conv1')
residual = resnet_utils.conv2d_same(residual, depth_bottleneck, 3, stride,rate=rate, scope='conv2') residual = slim.conv2d(residual, depth, [1, 1], stride=1,activation_fn=None, scope='conv3')'''
To this: runs only when depth==1024 or 2048 '''residual = slim.conv2d(inputs, depth_bottleneck, [1, 1], stride=1, scope='conv1') residual = LocallyConnected2D(filters=depth_bottleneck, kernel_size=3, strides = (2,2), data_format='channels_last',padding='same')(residual)
residual = slim.conv2d(residual, depth, [1, 1], stride=1, activation_fn=None, scope='conv3')'''
And also when I replace the layer and run it I get the following error:
Traceback (most recent call last): File "train.py", line 184, in
tf.app.run()
File "C:\Users\rohit\Anaconda3\lib\site-packages\tensorflow\python\platform\app.py", line 125, in run
_sys.exit(main(argv))
File "C:\Users\rohit\Anaconda3\lib\site-packages\tensorflow\python\util\deprecation.py", line 324, in new_func
return func(*args, kwargs)
File "train.py", line 180, in main
graph_hook_fn=graph_rewriter_fn)
File "C:\Users\rohit\Desktop\pretest\models-master\research\object_detection\legacy\trainer.py", line 291, in train
clones = model_deploy.create_clones(deploy_config, model_fn, [input_queue])
File "C:\Users\rohit\Desktop\pretest\models-master\research\slim\deployment\model_deploy.py", line 193, in create_clones
outputs = model_fn(*args, *kwargs)
File "C:\Users\rohit\Desktop\pretest\models-master\research\object_detection\legacy\trainer.py", line 204, in _create_losses
prediction_dict = detection_model.predict(images, true_image_shapes)
File "C:\Users\rohit\Desktop\pretest\models-master\research\object_detection\meta_architectures\faster_rcnn_meta_arch.py", line 647, in predict
image_shape) = self._extract_rpn_feature_maps(preprocessed_inputs)
File "C:\Users\rohit\Desktop\pretest\models-master\research\object_detection\meta_architectures\faster_rcnn_meta_arch.py", line 978, in _extract_rpn_feature_maps
scope=self.first_stage_feature_extractor_scope))
File "C:\Users\rohit\Desktop\pretest\models-master\research\object_detection\meta_architectures\faster_rcnn_meta_arch.py", line 163, in extract_proposal_features
return self._extract_proposal_features(preprocessed_inputs, scope)
File "C:\Users\rohit\Desktop\pretest\models-master\research\object_detection\models\faster_rcnn_resnet_v1_feature_extractor.py", line 138, in _extract_proposal_features
scope=var_scope)
File "C:\Users\rohit\Desktop\pretest\models-master\research\slim\nets\resnet_v1.py", line 311, in resnet_v1_50
reuse=reuse, scope=scope)
File "C:\Users\rohit\Desktop\pretest\models-master\research\slim\nets\resnet_v1.py", line 246, in resnet_v1
store_non_strided_activations)
File "C:\Users\rohit\Anaconda3\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py", line 182, in func_with_args
return func(args, current_args)
File "C:\Users\rohit\Desktop\pretest\models-master\research\slim\nets\resnet_utils.py", line 195, in stack_blocks_dense
net = block.unit_fn(net, rate=rate, *dict(unit, stride=1))
File "C:\Users\rohit\Anaconda3\lib\site-packages\tensorflow\contrib\framework\python\ops\arg_scope.py", line 182, in func_with_args
return func(args, **current_args)
File "C:\Users\rohit\Desktop\pretest\models-master\research\slim\nets\resnet_v1.py", line 134, in bottleneck
residual = LocallyConnected2D(filters=depth_bottleneck, kernel_size=3, strides = (2,2), data_format='channels_last')(residual)
File "C:\Users\rohit\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 538, in call
self._maybe_build(inputs)
File "C:\Users\rohit\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py", line 1603, in _maybe_build
self.build(input_shapes)
File "C:\Users\rohit\Anaconda3\lib\site-packages\tensorflow\python\keras\utils\tf_utils.py", line 151, in wrapper
output_shape = fn(instance, input_shape)
File "C:\Users\rohit\Anaconda3\lib\site-packages\tensorflow\python\keras\layers\local.py", line 445, in build
'the inputs shape ' + str(input_shape))
ValueError: The spatial dimensions of the inputs to a LocallyConnected2D layer should be fully-defined, but layer received the inputs shape (1, None, None, 256)