Need help with programming assignment

{moderator edit: code removed - not allowed}

def one_hot_matrix_test(target):
label = tf.constant(1)
depth = 4
result = target(label, depth)
print(“Test 1:”,result)
assert result.shape[0] == depth, “Use the parameter depth”
assert np.allclose(result, [0., 1. ,0., 0.] ), “Wrong output. Use tf.one_hot”
label_2 = [2]
result = target(label_2, depth)
print(“Test 2:”, result)
assert result.shape[0] == depth, “Use the parameter depth”
assert np.allclose(result, [0., 0. ,1., 0.] ), “Wrong output. Use tf.reshape as instructed”

print("\033[92mAll test passed")

one_hot_matrix_test(one_hot_matrix)
what will be the value of one_hot?? i tried things but didnt work

You have to write your code here. Replace the None with the correct terms. Read the instruction again to find out how to do this code.

1 Like

I wrote one_hot = tf.one_hot(label,depth,axis=0)
one_hot= tf.reshape(one_hot,shape=[-1,1])
But it is not working

This is the incorrect shape.

This is the correct shape.

You are supposed to change the None only, not the other things.