【问题标题】:Here is some Keras code. I don't understand what "(x)" means这是一些 Keras 代码。我不明白“(x)”是什么意思
【发布时间】:2018-09-12 10:21:00
【问题描述】:
output_tensor = layers.Dense(10, activation='softmax')(x)

以下是 keras 中的一些代码。我不明白(x) 在调用方法的上下文中是什么意思。谁能帮帮我?

【问题讨论】:

标签: python tensorflow machine-learning deep-learning keras


【解决方案1】:

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>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-01-09
    • 1970-01-01
    • 2014-12-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多