Lab ID: gtizubcyvtpv

I get this error. My weights and cam are of shape (1024,).

My debug:

Weights Shape: (1024,)

cam is :::: [<tf.Tensor ‘mul_5120:0’ shape=(?, ?, ?, 1024) dtype=float32>

<tf.Tensor ‘mul_5121:0’ shape=(?, ?, ?, 1024) dtype=float32>

<tf.Tensor ‘mul_5122:0’ shape=(?, ?, ?, 1024) dtype=float32> …

<tf.Tensor ‘mul_6141:0’ shape=(?, ?, ?, 1024) dtype=float32>

<tf.Tensor ‘mul_6142:0’ shape=(?, ?, ?, 1024) dtype=float32>

<tf.Tensor ‘mul_6143:0’ shape=(?, ?, ?, 1024) dtype=float32>] and its shape is (1024,)

Program Output

TypeError Traceback (most recent call last)

in ()

2 ### this cell is NOT editable

3 reference = np.load(‘reference_cam.npy’)

----> 4 cam = grad_cam_test(grad_cam, im_path, mean, std, load_image_normalize, model, reference)

~/work/W3A1/public_tests.py in grad_cam_test(target, im_path, mean, std, load_image_normalize, model, reference)

11 im = grad_cam_test_case(target, im_path, mean, std, load_image_normalize, model)

12

—> 13 cam = target(model, im, 5, ‘conv5_block16_concat’) # Mass is class 5

14

15 # Loads reference CAM to compare our implementation with.

in grad_cam(input_model, image, category_index, layer_name)

132 # We’ll take care of the postprocessing.

133 H, W = image.shape[1], image.shape[2]

→ 134 cam = np.maximum(cam, 0) # ReLU so we only get positive importance

135 cam = cv2.resize(cam, (W, H), cv2.INTER_NEAREST)

136 cam = cam / cam.max()

/opt/conda/lib/python3.6/site-packages/tensorflow/python/framework/ops.py in **bool**(self)

604 `TypeError`

.

605 “”"

→ 606 raise TypeError("Using a `tf.Tensor`

as a Python `bool`

is not allowed. "

607 "Use `if t is not None:`

instead of `if t:`

to test if a "

608 "tensor is defined, and use TensorFlow ops such as "

TypeError: Using a `tf.Tensor`

as a Python `bool`

is not allowed. Use `if t is not None:`

instead of `if t:`

to test if a tensor is defined, and use TensorFlow ops such as tf.cond to execute subgraphs conditioned on the value of a tensor.