Tensorflow_introduction - Exercise 3 - one_hot_matrix

Greetings,

I am stuck on this problem:
TypeError: tf__one_hot_matrix() missing 1 required positional argument: ‘depth’

when I run

one_hot = tf.reshape(tf.one_hot(label, depth, axis=0), (depth,1))
To troubleshoot, am I doing it correctly for one_hot function ?

Have you solved it yet? I can’t see any obvious mistakes with parameter naming. Try and rerun every cell in your notebook and see if it works after that.

2 Likes

Hey @jonaslalin

Thanks for the follow up. Yes it is already solved by changing the function header.
def one_hot_matrix(labels, depth=6):
:grinning: :grinning:

1 Like

Glad you fixed, it @mikepang98.

I think it’s not the first time I’ve seen this problem. In case others encounter it, the function header for one_hot_matrix read:

def one_hot_matrix(labels, depth):

Instead of:

def one_hot_matrix(label, depth=6):

So when it gets called by map with a single argument, it raises the error:

TypeError: tf__one_hot_matrix() missing 1 required positional argument: ‘depth’

Enjoy the rest of the course :slight_smile:

3 Likes