【发布时间】:2018-02-07 09:11:14
【问题描述】:
softmax 激活的 Keras docs 声明我可以指定激活应用于哪个轴。我的模型应该通过 k 矩阵 M 输出一个 n,其中 Mij 是 第 i 个字母是符号 j。
n = 7 # number of symbols in the ouput string (fixed)
k = len("0123456789") # the number of possible symbols
model = models.Sequential()
model.add(layers.Dense(16, activation='relu', input_shape=((N,))))
...
model.add(layers.Dense(n * k, activation=None))
model.add(layers.Reshape((n, k)))
model.add(layers.Dense(output_dim=n, activation='softmax(x, axis=1)'))
最后一行代码无法编译,因为我不知道如何正确指定 softmax 激活的轴(在我的例子中是 k 的轴)。
【问题讨论】:
标签: deep-learning keras activation-function