Пример #1
0
                 tied_weights=False)
train_2 = Train(
    dA_1_out,
    dA_2,
    algorithm=sgd.SGD(learning_rate=.05, batch_size=10, termination_criterion=EpochCounter(30), cost=cost_ae.MeanSquaredReconstructionError(), monitoring_batches=5, monitoring_dataset=dA_1_out)
)
train_2.main_loop()

#######################
####  Fine tuning  ####
#######################
### defining each layers ###
layer_1 = mlp.PretrainedLayer('layer_1', dA_1)
layer_2 = mlp.PretrainedLayer('layer_2', dA_2)
output_layer = mlp.Softmax(2, 'output', irange=.1)

### run fine tuning ###
layers = [layer_1, layer_2, output_layer]
main_mlp = mlp.MLP(layers, nvis=2)
train = Train(
    dataset,
    main_mlp,
    algorithm=sgd.SGD(learning_rate=.05, batch_size=10, termination_criterion=EpochCounter(400), monitoring_batches=5, monitoring_dataset=dataset)
)
train.main_loop()

###################
####  Testing  ####
###################
dataset.test(main_mlp)
Пример #2
0
from XOR import XOR

###############################
####  Setting for dataset  ####
###############################
dataset = XOR()

##########################
####  Setting for NN  ####
##########################
# create layers
hidden_layer = mlp.Sigmoid(layer_name='hidden', dim=3, irange=.1, init_bias=1.)
output_layer = mlp.Softmax(2, 'output', irange=.1)
layers = [hidden_layer, output_layer]
model = mlp.MLP(layers, nvis=2)

####################
####  Training  ####
####################
train = Train(
	dataset,
	model,
	algorithm=sgd.SGD(learning_rate=.05, batch_size=10, termination_criterion=EpochCounter(400))
)
train.main_loop()

#################
###  Testing  ###
#################
dataset.test(model)