TensorFlow Map Method

Hi!

Using TensorFlow for the first time, so please excuse me if the answer is obvious.

I’m wondering how the input parameters to the function are passed when the ‘map’ method is called with function as an argument. For eg

def one_hot_matrix(label, depth=6) - one_hot_matrix takes two input parameters; label and depth

new_y_test = y_test.map(one_hot_matrix) - one_hot_matrix is passed as an argument to map. Where is label and depth defined and passed?

Thanks

Hi, @rajsura82.

map is applying one_hot_matrix to each element of y_test, which is the only argument it receives (label). depth takes the default value of 6. If you wanted to give it a different value, let’s say 8, you could do:

new_y_test = y_test.map(lambda x: one_hot_matrix(x, 8))
1 Like