示例#1
0
                         border_mode="same")
                                                   
layer_5_de=SigmoidConvLayer(filter_size=(1,1),
                            num_filters=64,
                            num_channels=64,
                            fm_size=(1,1),
                            batch_size=batch_size,
                            border_mode="same")

# learning rate formula:
# r = 1 - 0.5*(ni/ntot)*(ni/ntot)
# ni = ith layer; ntot = number of layers


# layer_0
model_0=ConvAutoEncoder(layers=[layer_0_en, MaxPoolingSameSize(pool_size=(4,4)), layer_0_de])
out_0=model_0.fprop(images, corruption_level=corruption_level)
cost_0=mean_square_cost(out_0[-1], images)+L2_regularization(model_0.params, 0.005)
updates_0=gd_updates(cost=cost_0, params=model_0.params, method="sgd", learning_rate=0.1)

# layer_0 --> layer_1
model_0_to_1=FeedForward(layers=[layer_0_en, MaxPooling(pool_size=(2,2))]);
out_0_to_1=model_0_to_1.fprop(images);

# layer_1
model_1=ConvAutoEncoder(layers=[layer_1_en, MaxPoolingSameSize(pool_size=(2,2)), layer_1_de])
out_1=model_1.fprop(out_0_to_1[-1], corruption_level=corruption_level)
cost_1=mean_square_cost(out_1[-1], out_0_to_1[-1])+L2_regularization(model_1.params, 0.005)
updates_1=gd_updates(cost=cost_1, params=model_1.params, method="sgd", learning_rate=0.1)

# layer_1 --> layer_2
示例#2
0
                           num_filters=128,
                           num_channels=128,
                           fm_size=(1, 1),
                           batch_size=batch_size,
                           border_mode="same")

layer_4_de = SigmoidConvLayer(filter_size=(1, 1),
                              num_filters=128,
                              num_channels=128,
                              fm_size=(1, 1),
                              batch_size=batch_size,
                              border_mode="same")

# layer_0
model_0 = ConvAutoEncoder(
    layers=[layer_0_en,
            MaxPoolingSameSize(pool_size=(4, 4)), layer_0_de])
out_0 = model_0.fprop(images, corruption_level=corruption_level)
cost_0 = mean_square_cost(out_0[-1], images) + L2_regularization(
    model_0.params, 0.005)
updates_0 = gd_updates(cost=cost_0,
                       params=model_0.params,
                       method="sgd",
                       learning_rate=0.1)

# layer_0 --> layer_1
model_0_to_1 = FeedForward(
    layers=[layer_0_en, MaxPooling(pool_size=(4, 4))])
out_0_to_1 = model_0_to_1.fprop(images)

# layer_1
示例#3
0
                        border_mode="full")

layer_3_en=ReLUConvLayer(filter_size=(3,3),
                        num_filters=50,
                        num_channels=50,
                        fm_size=(18,18),
                        batch_size=batch_size)
                                               
layer_3_de=SigmoidConvLayer(filter_size=(3,3),
                        num_filters=50,
                        num_channels=50,
                        fm_size=(16,16),
                        batch_size=batch_size,
                        border_mode="full")

model_0=ConvAutoEncoder(layers=[layer_0_en, layer_0_de])
out_0=model_0.fprop(images, corruption_level=corruption_level)
cost_0=mean_square_cost(out_0[-1], images)+L2_regularization(model_0.params, 0.005)
updates_0=gd_updates(cost=cost_0, params=model_0.params, method="sgd", learning_rate=0.1)

model_1=ConvAutoEncoder(layers=[layer_1_en, layer_1_de])
out_1=model_1.fprop(out_0[0], corruption_level=corruption_level)
cost_1=mean_square_cost(out_1[-1], out_0[0])+L2_regularization(model_1.params, 0.005)
updates_1=gd_updates(cost=cost_1, params=model_1.params, method="sgd", learning_rate=0.1)

model_2=ConvAutoEncoder(layers=[layer_2_en, layer_2_de])
out_2=model_2.fprop(out_1[0], corruption_level=corruption_level)
cost_2=mean_square_cost(out_2[-1], out_1[0])+L2_regularization(model_2.params, 0.005)
updates_2=gd_updates(cost=cost_2, params=model_2.params, method="sgd", learning_rate=0.1)

model_3=ConvAutoEncoder(layers=[layer_3_en, layer_3_de])
示例#4
0
#                             border_mode="full")

# layer_3_en=ReLUConvLayer(filter_size=(3,3),
#                          num_filters=50,
#                          num_channels=50,
#                          fm_size=(18,18),
#                          batch_size=batch_size)
                                                   
# layer_3_de=SigmoidConvLayer(filter_size=(3,3),
#                             num_filters=50,
#                             num_channels=50,
#                             fm_size=(16,16),
#                             batch_size=batch_size,
#                             border_mode="full")

model_0=ConvAutoEncoder(layers=[layer_0_en, layer_0_de])
out_0=model_0.fprop(images, corruption_level=corruption_level)
cost_0=mean_square_cost(out_0[-1], images)+L2_regularization(model_0.params, 0.005)
updates_0=gd_updates(cost=cost_0, params=model_0.params, method="sgd", learning_rate=0.1)

## append a max-pooling layer

model_trans=FeedForward(layers=[layer_0_en, MaxPooling(pool_size=(2,2))]);
out_trans=model_trans.fprop(images);


model_1=ConvAutoEncoder(layers=[layer_1_en, layer_1_de])
out_1=model_1.fprop(out_trans[-1], corruption_level=corruption_level)
cost_1=mean_square_cost(out_1[-1], out_trans[-1])+L2_regularization(model_1.params, 0.005)
updates_1=gd_updates(cost=cost_1, params=model_1.params, method="sgd", learning_rate=0.1)
示例#5
0
#                             border_mode="full")

# layer_3_en=ReLUConvLayer(filter_size=(3,3),
#                          num_filters=50,
#                          num_channels=50,
#                          fm_size=(18,18),
#                          batch_size=batch_size)

# layer_3_de=SigmoidConvLayer(filter_size=(3,3),
#                             num_filters=50,
#                             num_channels=50,
#                             fm_size=(16,16),
#                             batch_size=batch_size,
#                             border_mode="full")

model_0 = ConvAutoEncoder(layers=[layer_0_en, layer_0_de])
out_0 = model_0.fprop(images, corruption_level=corruption_level)
cost_0 = mean_square_cost(out_0[-1], images) + L2_regularization(
    model_0.params, 0.005)
updates_0 = gd_updates(cost=cost_0,
                       params=model_0.params,
                       method="sgd",
                       learning_rate=0.1)

## append a max-pooling layer

model_trans = FeedForward(
    layers=[layer_0_en, MaxPooling(pool_size=(2, 2))])
out_trans = model_trans.fprop(images)

model_1 = ConvAutoEncoder(layers=[layer_1_en, layer_1_de])
示例#6
0
layer_1_en=ReLUConvLayer(filter_size=(2,2),
                         num_filters=50,
                         num_channels=50,
                         fm_size=(8,8),
                         batch_size=batch_size,
                         border_mode="same")
                                                   
layer_1_de=SigmoidConvLayer(filter_size=(2,2),
                            num_filters=50,
                            num_channels=50,
                            fm_size=(8,8),
                            batch_size=batch_size,
                            border_mode="same")


model_0=ConvAutoEncoder(layers=[layer_0_en, MaxPoolingSameSize(pool_size=(4,4)), layer_0_de])
out_0=model_0.fprop(images, corruption_level=corruption_level)
cost_0=mean_square_cost(out_0[-1], images)+L2_regularization(model_0.params, 0.005)
updates_0=gd_updates(cost=cost_0, params=model_0.params, method="sgd", learning_rate=0.1)

## append a max-pooling layer

model_trans=FeedForward(layers=[layer_0_en, MaxPooling(pool_size=(4,4))]);
out_trans=model_trans.fprop(images);


model_1=ConvAutoEncoder(layers=[layer_1_en, MaxPoolingSameSize(pool_size=(2,2)), layer_1_de])
out_1=model_1.fprop(out_trans[-1], corruption_level=corruption_level)
cost_1=mean_square_cost(out_1[-1], out_trans[-1])+L2_regularization(model_1.params, 0.005)
updates_1=gd_updates(cost=cost_1, params=model_1.params, method="sgd", learning_rate=0.1)
示例#7
0
                              border_mode="full")

layer_3_en = ReLUConvLayer(filter_size=(3, 3),
                           num_filters=50,
                           num_channels=50,
                           fm_size=(18, 18),
                           batch_size=batch_size)

layer_3_de = SigmoidConvLayer(filter_size=(3, 3),
                              num_filters=50,
                              num_channels=50,
                              fm_size=(16, 16),
                              batch_size=batch_size,
                              border_mode="full")

model_0 = ConvAutoEncoder(layers=[layer_0_en, layer_0_de])
out_0 = model_0.fprop(images, corruption_level=corruption_level)
cost_0 = mean_square_cost(out_0[-1], images) + L2_regularization(
    model_0.params, 0.005)
updates_0 = gd_updates(cost=cost_0,
                       params=model_0.params,
                       method="sgd",
                       learning_rate=0.1)

model_1 = ConvAutoEncoder(layers=[layer_1_en, layer_1_de])
out_1 = model_1.fprop(out_0[0], corruption_level=corruption_level)
cost_1 = mean_square_cost(out_1[-1], out_0[0]) + L2_regularization(
    model_1.params, 0.005)
updates_1 = gd_updates(cost=cost_1,
                       params=model_1.params,
                       method="sgd",