Downloading C4 W2A2

Hi,
i was trying to download and run te workspace of Transfer_learning_with_MobileNet_v1.

I followed the instructions according to (both splitting up/not splitting up the zipped file):

On my Windows notebook i can unzip and open the workspace, as well as run all cells until cell 17:

model2 = alpaca_model(IMG_SIZE, data_augmentation)

This cell gives me a lengthy error message:


NotImplementedError Traceback (most recent call last)
in
----> 1 model2 = alpaca_model(IMG_SIZE, data_augmentation)

in alpaca_model(image_shape, data_augmentation)
27
28 # apply data augmentation to the inputs
—> 29 x = data_augmentation(inputs)
30
31 # data preprocessing using the same weights the model was trained on

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py in call(self, *args, **kwargs)
923 # >> model = tf.keras.Model(inputs, outputs)
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

C:\ProgramData\Anaconda3\lib\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:

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\sequential.py in call(self, inputs, training, mask)
384 kwargs[‘training’] = training
385
→ 386 outputs = layer(inputs, **kwargs)
387
388 if len(nest.flatten(outputs)) != 1:

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\engine\base_layer.py in call(self, *args, **kwargs)
923 # >> model = tf.keras.Model(inputs, outputs)
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

C:\ProgramData\Anaconda3\lib\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:

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\layers\preprocessing\image_preprocessing.py in call(self, inputs, training)
820 interpolation=self.interpolation)
821
→ 822 output = tf_utils.smart_cond(training, random_rotated_inputs,
823 lambda: inputs)
824 output.set_shape(inputs.shape)

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\utils\tf_utils.py in smart_cond(pred, true_fn, false_fn, name)
62 return control_flow_ops.cond(
63 pred, true_fn=true_fn, false_fn=false_fn, name=name)
—> 64 return smart_module.smart_cond(
65 pred, true_fn=true_fn, false_fn=false_fn, name=name)
66

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\smart_cond.py in smart_cond(pred, true_fn, false_fn, name)
52 if pred_value is not None:
53 if pred_value:
—> 54 return true_fn()
55 else:
56 return false_fn()

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\layers\preprocessing\image_preprocessing.py in random_rotated_inputs()
816 return transform(
817 inputs,
→ 818 get_rotation_matrix(angles, img_hd, img_wd),
819 fill_mode=self.fill_mode,
820 interpolation=self.interpolation)

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\keras\layers\preprocessing\image_preprocessing.py in get_rotation_matrix(angles, image_height, image_width, name)
720 math_ops.cos(angles)[:, None],
721 y_offset[:, None],
→ 722 array_ops.zeros((num_angles, 2), dtypes.float32),
723 ],
724 axis=1)

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\util\dispatch.py in wrapper(*args, **kwargs)
199 “”“Call target, and fall back on dispatchers if there is a TypeError.”""
200 try:
→ 201 return target(*args, **kwargs)
202 except (TypeError, ValueError):
203 # Note: convert_to_eager_tensor currently raises a ValueError, not a

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py in wrapped(*args, **kwargs)
2745
2746 def wrapped(*args, **kwargs):
→ 2747 tensor = fun(*args, **kwargs)
2748 tensor._is_zeros_tensor = True
2749 return tensor

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py in zeros(shape, dtype, name)
2792 # Create a constant if it won’t be very big. Otherwise create a fill
2793 # op to prevent serialized GraphDefs from becoming too large.
→ 2794 output = _constant_if_small(zero, shape, dtype, name)
2795 if output is not None:
2796 return output

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\ops\array_ops.py in _constant_if_small(value, shape, dtype, name)
2730 def _constant_if_small(value, shape, dtype, name):
2731 try:
→ 2732 if np.prod(shape) < 1000:
2733 return constant(value, shape=shape, dtype=dtype, name=name)
2734 except TypeError:

<array_function internals> in prod(*args, **kwargs)

C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py in prod(a, axis, dtype, out, keepdims, initial, where)
3028 10
3029 “”"
→ 3030 return _wrapreduction(a, np.multiply, ‘prod’, axis, dtype, out,
3031 keepdims=keepdims, initial=initial, where=where)
3032

C:\ProgramData\Anaconda3\lib\site-packages\numpy\core\fromnumeric.py in _wrapreduction(obj, ufunc, method, axis, dtype, out, **kwargs)
85 return reduction(axis=axis, out=out, **passkwargs)
86
—> 87 return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
88
89

C:\ProgramData\Anaconda3\lib\site-packages\tensorflow\python\framework\ops.py in array(self)
843
844 def array(self):
→ 845 raise NotImplementedError(
846 “Cannot convert a symbolic Tensor ({}) to a numpy array.”
847 " This error may indicate that you’re trying to pass a Tensor to"

NotImplementedError: Cannot convert a symbolic Tensor (sequential_1/random_rotation_1/rotation_matrix_1/strided_slice:0) to a numpy array. This error may indicate that you’re trying to pass a Tensor to a NumPy call, which is not supported

The notebook worked without problems in the coursera environment.
Any hint on what might be the problem here?

Hi Ingmar,

This appears to be due to versioning. You can check if you use the same versions of NumPy, Python, and Tensorflow as in the coursera environment. More customized suggestions for resolving it are here.

Ok, this worked. I had trouble finding working package version combinations though.
I ran the following in the coursera environment to know which versions are used:

from platform import python_version
print (python_version())
print (tf.version)
print (np.version)

The output was:
3.7.6
2.3.0
1.18.4

Then i created a virtual environment in Anaconda for Jupyter with the above package versions which worked fine.

1 Like