0

While learning tensorflow, I am confused with code like:

x = tf.keras.layers.Dropout(0.2)(x)
    

So I try to print the x:

print('x before', x)
x before Tensor("global_average_pooling2d_1/Mean:0", shape=(None, 1280), dtype=float32)

x = tf.keras.layers.Dropout(0.2)(x)
print('x after', x)
x after Tensor("dropout/cond/Identity:0", shape=(None, 1280), dtype=float32)

My understanding is: 0.2 is the parameter to the function, but what is this (x) syntax?

Any reference would be appreicated

Tianyun Ling
  • 1,045
  • 1
  • 9
  • 24
  • You create a layer with the call to Dropout(0.2), and that layer is callable to add it to your graph. So afterwards x is the output of the dropout layouer, and the original x is the input. – matt Sep 14 '20 at 20:12
  • 1
    https://keras.io/api/layers/ the very first example describes it. you pass the input to the argument of the layer you create. – matt Sep 14 '20 at 20:13

0 Answers0