Ubuntu 16.04, Keras 2.1.3, Tensorflow 1.4.1, Tensorflow-gpu 1.4.1. Using the GPU.
Previous steps are fine, at "Building our network' I have a problem.
I commented out code so that only these lines execute
from keras import layers
from keras import models
model = models.Sequential()
model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(150, 150, 3)))
model.add(layers.MaxPooling2D((2, 2)))
And I get the following trace
InvalidArgumentError Traceback (most recent call last)
~/.local/lib/python3.5/site-packages/tensorflow/python/framework/common_shapes.py in _call_cpp_shape_fn_impl(op, input_tensors_needed, input_tensors_as_shapes_needed, require_shape_fn)
685 graph_def_version, node_def_str, input_shapes, input_tensors,
--> 686 input_tensors_as_shapes, status)
687 except errors.InvalidArgumentError as err:
~/.local/lib/python3.5/site-packages/tensorflow/python/framework/errors_impl.py in exit(self, type_arg, value_arg, traceback_arg)
472 compat.as_text(c_api.TF_Message(self.status.status)),
--> 473 c_api.TF_GetCode(self.status.status))
474 # Delete the underlying status object from memory otherwise it stays alive
InvalidArgumentError: Negative dimension size caused by subtracting 2 from 1 for 'max_pooling2d_2/MaxPool' (op: 'MaxPool') with input shapes: [?,32,148,1].
During handling of the above exception, another exception occurred:
ValueError Traceback (most recent call last)
in ()
5 model.add(layers.Conv2D(32, (3, 3), activation='relu',
6 input_shape=(150, 150, 3)))
----> 7 model.add(layers.MaxPooling2D((2, 2)))
8 #model.add(layers.Conv2D(64, (3, 3), activation='relu'))
9 #model.add(layers.MaxPooling2D((2, 2)))
~/.local/lib/python3.5/site-packages/keras/models.py in add(self, layer)
490 output_shapes=[self.outputs[0]._keras_shape])
491 else:
--> 492 output_tensor = layer(self.outputs[0])
493 if isinstance(output_tensor, list):
494 raise TypeError('All layers in a Sequential model '
~/.local/lib/python3.5/site-packages/keras/engine/topology.py in call(self, inputs, **kwargs)
615
616 # Actually call the layer, collecting output(s), mask(s), and shape(s).
--> 617 output = self.call(inputs, **kwargs)
618 output_mask = self.compute_mask(inputs, previous_mask)
619
~/.local/lib/python3.5/site-packages/keras/layers/pooling.py in call(self, inputs)
156 strides=self.strides,
157 padding=self.padding,
--> 158 data_format=self.data_format)
159 return output
160
~/.local/lib/python3.5/site-packages/keras/layers/pooling.py in _pooling_function(self, inputs, pool_size, strides, padding, data_format)
219 output = K.pool2d(inputs, pool_size, strides,
220 padding, data_format,
--> 221 pool_mode='max')
222 return output
223
~/.local/lib/python3.5/site-packages/keras/backend/tensorflow_backend.py in pool2d(x, pool_size, strides, padding, data_format, pool_mode)
3652 x = tf.nn.max_pool(x, pool_size, strides,
3653 padding=padding,
-> 3654 data_format=tf_data_format)
3655 elif pool_mode == 'avg':
3656 x = tf.nn.avg_pool(x, pool_size, strides,
~/.local/lib/python3.5/site-packages/tensorflow/python/ops/nn_ops.py in max_pool(value, ksize, strides, padding, data_format, name)
1956 padding=padding,
1957 data_format=data_format,
-> 1958 name=name)
1959
1960
~/.local/lib/python3.5/site-packages/tensorflow/python/ops/gen_nn_ops.py in _max_pool(input, ksize, strides, padding, data_format, name)
2804 _, _, _op = _op_def_lib._apply_op_helper(
2805 "MaxPool", input=input, ksize=ksize, strides=strides, padding=padding,
-> 2806 data_format=data_format, name=name)
2807 _result = _op.outputs[:]
2808 _inputs_flat = _op.inputs
~/.local/lib/python3.5/site-packages/tensorflow/python/framework/op_def_library.py in _apply_op_helper(self, op_type_name, name, **keywords)
785 op = g.create_op(op_type_name, inputs, output_types, name=scope,
786 input_types=input_types, attrs=attr_protos,
--> 787 op_def=op_def)
788 return output_structure, op_def.is_stateful, op
789
~/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py in create_op(self, op_type, inputs, dtypes, input_types, name, attrs, op_def, compute_shapes, compute_device)
2956 op_def=op_def)
2957 if compute_shapes:
-> 2958 set_shapes_for_outputs(ret)
2959 self._add_op(ret)
2960 self._record_op_seen_by_control_dependencies(ret)
~/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py in set_shapes_for_outputs(op)
2207 shape_func = _call_cpp_shape_fn_and_require_op
2208
-> 2209 shapes = shape_func(op)
2210 if shapes is None:
2211 raise RuntimeError(
~/.local/lib/python3.5/site-packages/tensorflow/python/framework/ops.py in call_with_requiring(op)
2157
2158 def call_with_requiring(op):
-> 2159 return call_cpp_shape_fn(op, require_shape_fn=True)
2160
2161 _call_cpp_shape_fn_and_require_op = call_with_requiring
~/.local/lib/python3.5/site-packages/tensorflow/python/framework/common_shapes.py in call_cpp_shape_fn(op, require_shape_fn)
625 res = _call_cpp_shape_fn_impl(op, input_tensors_needed,
626 input_tensors_as_shapes_needed,
--> 627 require_shape_fn)
628 if not isinstance(res, dict):
629 # Handles the case where _call_cpp_shape_fn_impl calls unknown_shape(op).
~/.local/lib/python3.5/site-packages/tensorflow/python/framework/common_shapes.py in _call_cpp_shape_fn_impl(op, input_tensors_needed, input_tensors_as_shapes_needed, require_shape_fn)
689 missing_shape_fn = True
690 else:
--> 691 raise ValueError(err.message)
692
693 if missing_shape_fn:
ValueError: Negative dimension size caused by subtracting 2 from 1 for 'max_pooling2d_2/MaxPool' (op: 'MaxPool') with input shapes: [?,32,148,1].