【发布时间】:2018-09-12 10:21:00
【问题描述】:
output_tensor = layers.Dense(10, activation='softmax')(x)
以下是 keras 中的一些代码。我不明白(x) 在调用方法的上下文中是什么意思。谁能帮帮我?
【问题讨论】:
-
表示函数调用,值为
x
标签: python tensorflow machine-learning deep-learning keras
output_tensor = layers.Dense(10, activation='softmax')(x)
以下是 keras 中的一些代码。我不明白(x) 在调用方法的上下文中是什么意思。谁能帮帮我?
【问题讨论】:
x
标签: python tensorflow machine-learning deep-learning keras
layers.Dense 返回一个可调用对象,然后您可以调用该对象并将x 作为输入。
Dense 函数创建层,层是必须给定其他东西作为输入的东西。当您调用图层本身时,会指定此“其他内容”。
也许这个 sn-p 会有所帮助:
In [1]: from keras import layers
Using TensorFlow backend.
In [2]: x = layers.Input((1, ))
In [3]: l = layers.Dense(10, activation='softmax')
In [4]: callable(l)
Out[4]: True
In [5]: l(x)
Out[5]: <tf.Tensor 'dense_1/Softmax:0' shape=(?, 10) dtype=float32>
【讨论】: