我有一个 CNN-LSTM 架构。现在,我想对中间层的特征实施概率分布,比如混合正态分布。我怎样才能在 Keras 中做到这一点?
我看到了 keras 的 MDN 实现(https://github.com/cpmpercussion/keras-mdn-layer)。但这要求它应该用作网络的最后一层。另外,我查看了 tensorflow_probability,但我不确定是否可以为此使用 tensorflow_probability 层。
enc.add(LSTM(units=64,activation='tanh',return_sequences=False))
# probability layer
enc.add(tfpl.MixtureNormal(num_classes,[64]))
enc.add(Dense(units=num_classes,activation='softmax'))
当我尝试上面的代码时,它给了我一个错误如下:
tensorflow.python.framework.errors_impl.InvalidArgumentError: 2 root error(s) found.
(0) Invalid argument: Number of ways to split should evenly divide the split dimension, but got split_dim 2 (size = 15) and num_split 2
[[{{node mixture_normal/MixtureSameFamily/independent_normal/IndependentNormal/split}}]]
[[metrics/categorical_accuracy/Identity/_251]]
(1) Invalid argument: Number of ways to split should evenly divide the split dimension, but got split_dim 2 (size = 15) and num_split 2
[[{{node mixture_normal/MixtureSameFamily/independent_normal/IndependentNormal/split}}]]