Well, the call to data_augmentation
was part of the problem, I called it as I did because in the example it is used as augmented_image = data_augmentation(tf.expand_dims(first_image, 0))
.
Just putting the inputs tensor in runs without error, but there are still issues. I took the hint that decode_predictions
is not what I want to use and tried calling base_model
again. If that wasn’t what I wanted to do either, I am really confused.
base_model
at the last step results in:
WARNING:tensorflow:Model was constructed with shape (None, 160, 160, 3) for input Tensor("input_52:0", shape=(None, 160, 160, 3), dtype=float32), but it was called on an input with incompatible shape (None, 2, 2, 1280).
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-68-11ffc7a7acb3> in <module>
----> 1 model2 = alpaca_model(IMG_SIZE, data_augmentation)
<ipython-input-67-71e36ff5ca6d> in alpaca_model(image_shape, data_augmentation)
49
50 # use a prediction layer with one neuron (as a binary classifier only needs one)
---> 51 outputs = base_model(x)
52 # print("outputs are", outputs)
53
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in __call__(self, *args, **kwargs)
924 if _in_functional_construction_mode(self, inputs, args, kwargs, input_list):
925 return self._functional_construction_call(inputs, args, kwargs,
--> 926 input_list)
927
928 # Maintains info about the `Layer.call` stack.
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in _functional_construction_call(self, inputs, args, kwargs, input_list)
1115 try:
1116 with ops.enable_auto_cast_variables(self._compute_dtype_object):
-> 1117 outputs = call_fn(cast_inputs, *args, **kwargs)
1118
1119 except errors.OperatorNotAllowedInGraphError as e:
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/functional.py in call(self, inputs, training, mask)
384 """
385 return self._run_internal_graph(
--> 386 inputs, training=training, mask=mask)
387
388 def compute_output_shape(self, input_shape):
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/functional.py in _run_internal_graph(self, inputs, training, mask)
506
507 args, kwargs = node.map_arguments(tensor_dict)
--> 508 outputs = node.layer(*args, **kwargs)
509
510 # Update tensor_dict.
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in __call__(self, *args, **kwargs)
924 if _in_functional_construction_mode(self, inputs, args, kwargs, input_list):
925 return self._functional_construction_call(inputs, args, kwargs,
--> 926 input_list)
927
928 # Maintains info about the `Layer.call` stack.
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in _functional_construction_call(self, inputs, args, kwargs, input_list)
1090 # TODO(reedwm): We should assert input compatibility after the inputs
1091 # are casted, not before.
-> 1092 input_spec.assert_input_compatibility(self.input_spec, inputs, self.name)
1093 graph = backend.get_graph()
1094 # Use `self._name_scope()` to avoid auto-incrementing the name.
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/input_spec.py in assert_input_compatibility(input_spec, inputs, layer_name)
214 ' incompatible with the layer: expected axis ' + str(axis) +
215 ' of input shape to have value ' + str(value) +
--> 216 ' but received input with shape ' + str(shape))
217 # Check shape.
218 if spec.shape is not None:
ValueError: Input 0 of layer Conv1 is incompatible with the layer: expected axis -1 of input shape to have value 3 but received input with shape [None, 3, 3, 1280]
Edit: Oh wait, I should be using Dense
for the output layer, right?