Image Segmentation_Unet _v2

I need need help in on the Graded Function of conv_block. I have tried all different ways, I can not figure out the mistake. I gives me the error Expected value does not match with the input value. I someone can help me, I can send the portion of the code or my entire worked on assignment.


Abdus Shamim Khan

Hi, Askhan.

It is probably enough to show us the actual output of the failing test, because that will show the difference between what it expects and what it saw. That’s usually enough for us to give some advice about where to look and what to look for. Please just “copy/paste” the full output that you get when you run the test that fails.

Hi Paul

This is the message I get. I would appreciate your suggestions. Thanks

Test failed
Expected value

[‘Conv2D’, (None, 96, 128, 1024), 28672, ‘same’, ‘relu’, ‘HeNormal’]

does not match the input value:

[‘Conv2D’, (None, 96, 128, 32), 896, ‘same’, ‘relu’, ‘HeNormal’]

Hi, Askhan.

Ok, by looking at the “expected values” for the first and second test, notice that you passed the first test. In the second test, you fail on the first Conv2D layer. So I would bet that what this means is that you are hard-coding the number of filters as 32 instead of using the input parameter is n_filters. That bug gets past the first test, since the input value is actually 32. But then it fails the second test because n_filters is 1024 in that case.

1 Like

Thanks Paul for your suggestions. It worked.
I have another problem, it is with unet_model.

I am pasting the error messages, will appreciate your input:

  1. ValueError: Layer conv2d_11 expects 1 inputs, but it received 2 input tensors. Inputs received: [<tf.Tensor ‘max_pooling2d_3/MaxPool:0’ shape=(None, 48, 64, 32) dtype=float32>, <tf.Tensor ‘conv2d_10/Relu:0’ shape=(None, 96, 128, 32) dtype=float32>]

  2. name ‘unet’ is not defined


Note that on the contracting path, each layer has two outputs, right? One of them feeds into the next layer and the second one feeds “across” as the shortcut input to the corresponding upsampling layer. Then on the upsampling layer, each layer just outputs one tensor.

So that means anytime you are taking input from one of the conv_block outputs, you need to select either the first one or the second one, depending on what you are doing, right? There is no case in which you take both outputs at once as inputs.

As to item 2), that usually means you have not run one of the earlier cells that produces that variable unet. Either that or you ran it and it threw an error, so it didn’t create anything. Try “Kernel → Restart and Clear Output” followed by “Cell → Run All”. Then scan through all the cells and make sure everything ran successfully.

thank you for your advice .
I had same problem and I solved it where I used hard coding in previous class for n_filters

1 Like

Hi Paul,

I have used n_filters ( conv = Conv2D(n_filters,) in both layers, when I run, first layer test passes but second layer just gives the following error:
est failed
Expected value

[‘Conv2D’, (None, 96, 128, 1024), 28672, ‘same’, ‘relu’, ‘HeNormal’]

does not match the input value:

[‘Conv2D’, (None, 96, 128, 32), 896, ‘same’, ‘relu’, ‘HeNormal’]

AssertionError Traceback (most recent call last)
30 print(layer)
—> 32 comparator(summary(model2), output2)

/tf/W3A2/ in comparator(learner, instructor)
17 “\n\n does not match the input value: \n\n”,
18 colored(f"{a}", “red”))
—> 19 raise AssertionError(“Error in test”)
20 print(colored(“All tests passed!”, “green”))

AssertionError: Error in test

Can you please help with a suggestion to resolve this?