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

L1-L2正则化的不同系数

我想对网络的权重同时应用L1和L2正则化。然而,我找不…

使用scikit-learn的无监督方法将列表分类成不同组别,有没有办法?

我有一系列实例,每个实例都有一份列表,代表它所遵循的不…

f1_score metric in lightgbm

我想使用自定义指标f1_score来训练一个lgb模型…

通过相关系数矩阵进行特征选择

我在测试不同的算法时,如逻辑回归、高斯朴素贝叶斯、随机…

可以将机器学习库用于流式输入和输出吗?

已关闭。此问题需要更加聚焦。目前不接受回答。 想要改进…

在TensorFlow中,queue.dequeue_up_to()方法的用途是什么?

我对这个方法感到非常困惑,特别是当我发现这个令人费解的…

发表回复

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