本文整理匯總了Python中cntk.layers.Dense方法的典型用法代碼示例。如果您正苦於以下問題:Python layers.Dense方法的具體用法?Python layers.Dense怎麽用?Python layers.Dense使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cntk.layers
的用法示例。
在下文中一共展示了layers.Dense方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: create_convolutional_neural_network
# 需要導入模塊: from cntk import layers [as 別名]
# 或者: from cntk.layers import Dense [as 別名]
def create_convolutional_neural_network(input_vars, out_dims, dropout_prob=0.0):
convolutional_layer_1 = Convolution((5, 5), 32, strides=1, activation=cntk.ops.relu, pad=True, init=gaussian(), init_bias=0.1)(input_vars)
pooling_layer_1 = MaxPooling((2, 2), strides=(2, 2), pad=True)(convolutional_layer_1)
convolutional_layer_2 = Convolution((5, 5), 64, strides=1, activation=cntk.ops.relu, pad=True, init=gaussian(), init_bias=0.1)(pooling_layer_1)
pooling_layer_2 = MaxPooling((2, 2), strides=(2, 2), pad=True)(convolutional_layer_2)
convolutional_layer_3 = Convolution((5, 5), 128, strides=1, activation=cntk.ops.relu, pad=True, init=gaussian(), init_bias=0.1)(pooling_layer_2)
pooling_layer_3 = MaxPooling((2, 2), strides=(2, 2), pad=True)(convolutional_layer_3)
fully_connected_layer = Dense(1024, activation=cntk.ops.relu, init=gaussian(), init_bias=0.1)(pooling_layer_3)
dropout_layer = Dropout(dropout_prob)(fully_connected_layer)
output_layer = Dense(out_dims, activation=None, init=gaussian(), init_bias=0.1)(dropout_layer)
return output_layer
# Define the input to the neural network
示例2: create_convolutional_neural_network
# 需要導入模塊: from cntk import layers [as 別名]
# 或者: from cntk.layers import Dense [as 別名]
def create_convolutional_neural_network(input_vars, out_dims):
convolutional_layer_1 = Convolution((5, 5), 32, strides=1, activation=cntk.ops.relu, pad=True,
init=glorot_normal(), init_bias=0.1)
pooling_layer_1 = MaxPooling((2, 2), strides=(2, 2), pad=True)
convolutional_layer_2 = Convolution((5, 5), 64, strides=1, activation=cntk.ops.relu, pad=True,
init=glorot_normal(), init_bias=0.1)
pooling_layer_2 = MaxPooling((2, 2), strides=(2, 2), pad=True)
convolutional_layer_3 = Convolution((5, 5), 128, strides=1, activation=cntk.ops.relu, pad=True,
init=glorot_normal(), init_bias=0.1)
pooling_layer_3 = MaxPooling((2, 2), strides=(2, 2), pad=True)
fully_connected_layer = Dense(1024, activation=cntk.ops.relu, init=glorot_normal(), init_bias=0.1)
output_layer = Dense(out_dims, activation=None, init=glorot_normal(), init_bias=0.1)
model = Sequential([convolutional_layer_1, pooling_layer_1,
convolutional_layer_2, pooling_layer_2,
#convolutional_layer_3, pooling_layer_3,
fully_connected_layer,
output_layer])(input_vars)
return model
示例3: create_cifar10_model
# 需要導入模塊: from cntk import layers [as 別名]
# 或者: from cntk.layers import Dense [as 別名]
def create_cifar10_model(input, num_stack_layers, num_classes):
c_map = [16, 32, 64]
conv = conv_bn_relu(input, (3,3), c_map[0])
r1 = resnet_basic_stack(conv, num_stack_layers, c_map[0])
r2_1 = resnet_basic_inc(r1, c_map[1])
r2_2 = resnet_basic_stack(r2_1, num_stack_layers-1, c_map[1])
r3_1 = resnet_basic_inc(r2_2, c_map[2])
r3_2 = resnet_basic_stack(r3_1, num_stack_layers-1, c_map[2])
# Global average pooling and output
pool = AveragePooling(filter_shape=(8,8))(r3_2)
z = Dense(num_classes)(pool)
return z
示例4: create_multi_layer_neural_network
# 需要導入模塊: from cntk import layers [as 別名]
# 或者: from cntk.layers import Dense [as 別名]
def create_multi_layer_neural_network(input_vars, out_dims, num_hidden_layers):
input_dims = input_vars.shape[0]
num_hidden_neurons = input_dims**3
hidden_layer = lambda: Dense(num_hidden_neurons, activation=cntk.ops.relu)
output_layer = Dense(out_dims, activation=None)
model = Sequential([LayerStack(num_hidden_layers, hidden_layer),
output_layer])(input_vars)
return model
示例5: create_pooling_neural_network
# 需要導入模塊: from cntk import layers [as 別名]
# 或者: from cntk.layers import Dense [as 別名]
def create_pooling_neural_network(input_vars, out_dims):
hidden_layer_1 = Dense(2, activation=cntk.ops.relu)
hidden_layer_2 = Dense(16, activation=cntk.ops.relu)
output_layer = Dense(out_dims, activation=None)
model = Sequential([hidden_layer_1,
hidden_layer_2,
output_layer])(input_vars)
return model
示例6: create_multi_layer_neural_network
# 需要導入模塊: from cntk import layers [as 別名]
# 或者: from cntk.layers import Dense [as 別名]
def create_multi_layer_neural_network(input_vars, out_dims, num_hidden_layers):
num_hidden_neurons = 128
hidden_layer = lambda: Dense(num_hidden_neurons, activation=cntk.ops.relu)
output_layer = Dense(out_dims, activation=None)
model = Sequential([LayerStack(num_hidden_layers, hidden_layer),
output_layer])(input_vars)
return model