CNTK没有LeakyReLU属性

在构建这样的CNN模型时:

# 构建模型的函数
def create_model(features):
    with C.layers.default_options(init=C.glorot_uniform(), activation=C.LeakyReLU):
        h = features
        h = C.layers.Convolution2D(filter_shape=(5,5),
                                   num_filters=8,
                                   strides=(2,2),
                                   pad=True, name='first_conv')(h)
        h = C.layers.Convolution2D(filter_shape=(5,5),
                                   num_filters=16,
                                   strides=(2,2),
                                   pad=True, name='second_conv')(h)
        r = C.layers.Dense(num_output_classes, activation=None, name='classify')(h)
        return r
# 创建模型
z = create_model(x)
# 打印不同组件的输出形状/参数
print("第一个卷积层的输出形状:", z.first_conv.shape)
print("最后一个全连接层的偏置值:", z.classify.b.value)

我遇到了以下错误:

AttributeError Traceback (most recent call last) in () 1 # Create the model —-> 2 z = create_model(x) 3 4 # Print the output shapes / parameters of different components 5 print(“Output Shape of the first convolution layer:”, z.first_conv.shape)

in create_model(features) 2 3 def create_model(features): —-> 4 with C.layers.default_options(init=C.glorot_uniform(), activation=C.LeakyReLU): 5 h = features 6 h = C.layers.Convolution2D(filter_shape=(5,5),

AttributeError: module ‘cntk’ has no attribute ‘LeakyReLU’

我是深度学习的新手,所以可能忽略了一些简单的问题。任何帮助都非常感谢。谢谢!


回答:

尝试使用C.leaky_relu

>>> C.leaky_relu([[-1, -0.5, 0, 1, 2]]).eval()array([[-0.01 , -0.005,  0.   ,  1.   ,  2.   ]], dtype=float32)

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注