繁体   English   中英

应用 scipy stats function 作为 Keras 神经网络中的层

[英]Apply scipy stats function as a layer in a Keras neural network

我想在 Keras 神经网络中应用 scipy stats function 作为层,如下所示:

from scipy import stats

class BoxCox(layers.Layer):

    def call(self, inputs):
        return stats.boxcox(inputs)

# part of usage in model
x1 = layers.Dense(81)(x)
x1 = BoxCox()(x1)
x1 = layers.Dropout(0.25)(x1)

stats库函数不接受张量存在问题。 例如,错误消息是

NotImplementedError: Cannot convert a symbolic Tensor (activation_12/IdentityN:0) to a numpy array. This error may indicate that you're trying to pass a Tensor to a NumPy call, which is not supported

有什么方法可以将这样的 function 作为神经网络中的一个层运行?

非常感谢您的帮助。 谢谢!

层必须支持梯度的反向传播。 只有 tensorflow function 支持它。 您不能使用其他功能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM