def load_ae_encoder(path, nonlinearity=sigmoid):
nn = sio.loadmat(path)
w1 = nn['w1']
w2 = nn['w2']
w3 = nn['w3']
w4 = nn['w4']
b1 = nn['b1'][0]
b2 = nn['b2'][0]
b3 = nn['b3'][0]
b4 = nn['b4'][0]
layers = [
(InputLayer, {'name': 'input', 'shape': (None, 1500)}),
(DenseLayer, {'name': 'l1', 'num_units': 2000, 'nonlinearity': nonlinearity, 'W': w1, 'b': b1}),
(DenseLayer, {'name': 'l2', 'num_units': 1000, 'nonlinearity': nonlinearity, 'W': w2, 'b': b2}),
(DenseLayer, {'name': 'l3', 'num_units': 500, 'nonlinearity': nonlinearity, 'W': w3, 'b': b3}),
(DenseLayer, {'name': 'l4', 'num_units': 50, 'nonlinearity': linear, 'W': w4, 'b': b4})
]
'''
dbn = NeuralNet(
layers=layers,
max_epochs=30,
objective_loss_function=squared_error,
update=nesterov_momentum,
regression=True,
verbose=1,
update_learning_rate=0.001,
update_momentum=0.05,
objective_l2=0.005,
)
'''
dbn = NeuralNet(
layers=layers,
max_epochs=10,
objective_loss_function=squared_error,
update=adadelta,
regression=True,
verbose=1,
update_learning_rate=0.01,
# update_learning_rate=0.001,
# update_momentum=0.05,
objective_l2=0.005,
)
return dbn
评论列表
文章目录