Issues with creating vgg = Vgg16() object

Having issues with creating vgg object, help ?
I tried changing theano/tensorflow
hardware and software

  • titanx maxwell
  • nvcc release 8.0, V8.0.44
  • using anaconda2

Problem got resolved, I updated theanorc file and things seems to be fine.
updated keras to use theano instead of tensorflow.
tensorflow has the issue specified


ValueError Traceback (most recent call last)
in ()
----> 1 vgg = Vgg16()

/home/bicepjai/Projects/online-classes/fast_ai/lesson1/vgg16.py in init(self, size, include_top)
31 def init(self, size=(224,224), include_top=True):
32 self.FILE_PATH = ‘http://www.platform.ai/models/
—> 33 self.create(size, include_top)
34 self.get_classes()
35

/home/bicepjai/Projects/online-classes/fast_ai/lesson1/vgg16.py in create(self, size, include_top)
73
74 self.ConvBlock(2, 64)
—> 75 self.ConvBlock(2, 128)
76 self.ConvBlock(3, 256)
77 self.ConvBlock(3, 512)

/home/bicepjai/Projects/online-classes/fast_ai/lesson1/vgg16.py in ConvBlock(self, layers, filters)
55 model.add(ZeroPadding2D((1, 1)))
56 model.add(Convolution2D(filters, 3, 3, activation=‘relu’))
—> 57 model.add(MaxPooling2D((2, 2), strides=(2, 2)))
58
59

/home/bicepjai/Programs/anaconda2/envs/deepl/lib/python2.7/site-packages/keras/models.pyc in add(self, layer)
329 output_shapes=[self.outputs[0]._keras_shape])
330 else:
–> 331 output_tensor = layer(self.outputs[0])
332 if isinstance(output_tensor, list):
333 raise TypeError('All layers in a Sequential model ’

/home/bicepjai/Programs/anaconda2/envs/deepl/lib/python2.7/site-packages/keras/engine/topology.pyc in call(self, x, mask)
567 if inbound_layers:
568 # This will call layer.build() if necessary.
–> 569 self.add_inbound_node(inbound_layers, node_indices, tensor_indices)
570 # Outputs were already computed when calling self.add_inbound_node.
571 outputs = self.inbound_nodes[-1].output_tensors

/home/bicepjai/Programs/anaconda2/envs/deepl/lib/python2.7/site-packages/keras/engine/topology.pyc in add_inbound_node(self, inbound_layers, node_indices, tensor_indices)
630 # creating the node automatically updates self.inbound_nodes
631 # as well as outbound_nodes on inbound layers.
–> 632 Node.create_node(self, inbound_layers, node_indices, tensor_indices)
633
634 def get_output_shape_for(self, input_shape):

/home/bicepjai/Programs/anaconda2/envs/deepl/lib/python2.7/site-packages/keras/engine/topology.pyc in create_node(cls, outbound_layer, inbound_layers, node_indices, tensor_indices)
162
163 if len(input_tensors) == 1:
–> 164 output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))
165 output_masks = to_list(outbound_layer.compute_mask(input_tensors[0], input_masks[0]))
166 # TODO: try to auto-infer shape

/home/bicepjai/Programs/anaconda2/envs/deepl/lib/python2.7/site-packages/keras/layers/pooling.pyc in call(self, x, mask)
158 strides=self.strides,
159 border_mode=self.border_mode,
–> 160 dim_ordering=self.dim_ordering)
161 return output
162

/home/bicepjai/Programs/anaconda2/envs/deepl/lib/python2.7/site-packages/keras/layers/pooling.pyc in _pooling_function(self, inputs, pool_size, strides, border_mode, dim_ordering)
208 output = K.pool2d(inputs, pool_size, strides,
209 border_mode, dim_ordering,
–> 210 pool_mode=‘max’)
211 return output
212

/home/bicepjai/Programs/anaconda2/envs/deepl/lib/python2.7/site-packages/keras/backend/tensorflow_backend.pyc in pool2d(x, pool_size, strides, border_mode, dim_ordering, pool_mode)
2336
2337 if pool_mode == ‘max’:
-> 2338 x = tf.nn.max_pool(x, pool_size, strides, padding=padding)
2339 elif pool_mode == ‘avg’:
2340 x = tf.nn.avg_pool(x, pool_size, strides, padding=padding)

/home/bicepjai/Programs/anaconda2/envs/deepl/lib/python2.7/site-packages/tensorflow/python/ops/nn_ops.pyc in max_pool(value, ksize, strides, padding, data_format, name)
1615 padding=padding,
1616 data_format=data_format,
-> 1617 name=name)
1618
1619

/home/bicepjai/Programs/anaconda2/envs/deepl/lib/python2.7/site-packages/tensorflow/python/ops/gen_nn_ops.pyc in _max_pool(input, ksize, strides, padding, data_format, name)
1596 result = _op_def_lib.apply_op(“MaxPool”, input=input, ksize=ksize,
1597 strides=strides, padding=padding,
-> 1598 data_format=data_format, name=name)
1599 return result
1600

/home/bicepjai/Programs/anaconda2/envs/deepl/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.pyc in apply_op(self, op_type_name, name, **keywords)
757 op = g.create_op(op_type_name, inputs, output_types, name=scope,
758 input_types=input_types, attrs=attr_protos,
–> 759 op_def=op_def)
760 if output_structure:
761 outputs = op.outputs

/home/bicepjai/Programs/anaconda2/envs/deepl/lib/python2.7/site-packages/tensorflow/python/framework/ops.pyc in create_op(self, op_type, inputs, dtypes, input_types, name, attrs, op_def, compute_shapes, compute_device)
2240 original_op=self._default_original_op, op_def=op_def)
2241 if compute_shapes:
-> 2242 set_shapes_for_outputs(ret)
2243 self._add_op(ret)
2244 self._record_op_seen_by_control_dependencies(ret)

/home/bicepjai/Programs/anaconda2/envs/deepl/lib/python2.7/site-packages/tensorflow/python/framework/ops.pyc in set_shapes_for_outputs(op)
1615 shape_func = _call_cpp_shape_fn_and_require_op
1616
-> 1617 shapes = shape_func(op)
1618 if shapes is None:
1619 raise RuntimeError(

/home/bicepjai/Programs/anaconda2/envs/deepl/lib/python2.7/site-packages/tensorflow/python/framework/ops.pyc in call_with_requiring(op)
1566
1567 def call_with_requiring(op):
-> 1568 return call_cpp_shape_fn(op, require_shape_fn=True)
1569
1570 _call_cpp_shape_fn_and_require_op = call_with_requiring

/home/bicepjai/Programs/anaconda2/envs/deepl/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.pyc in call_cpp_shape_fn(op, input_tensors_needed, input_tensors_as_shapes_needed, debug_python_shape_fn, require_shape_fn)
608 res = _call_cpp_shape_fn_impl(op, input_tensors_needed,
609 input_tensors_as_shapes_needed,
–> 610 debug_python_shape_fn, require_shape_fn)
611 if not isinstance(res, dict):
612 # Handles the case where _call_cpp_shape_fn_impl calls unknown_shape(op).

/home/bicepjai/Programs/anaconda2/envs/deepl/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.pyc in _call_cpp_shape_fn_impl(op, input_tensors_needed, input_tensors_as_shapes_needed, debug_python_shape_fn, require_shape_fn)
673 missing_shape_fn = True
674 else:
–> 675 raise ValueError(err.message)
676
677 if missing_shape_fn:

ValueError: Negative dimension size caused by subtracting 2 from 1 for ‘MaxPool_15’ (op: ‘MaxPool’) with input shapes: [?,1,112,128].

Right, we use theano in this class, not tensorflow. So you should be fine now.

This isn’t clear to me. Where is the theanorc file located?
And what do you mean by “updated keras to use theano instead of tensorflow”?

Thanks,

Michael

OK I found it. it is under .keras in my home directory and it is called keras.json

watch the lesson1-overview and lesson1 videos. the details are explained in the video.