当前位置: 首页>>代码示例>>Python>>正文


Python NeuralNet.load_weights_from方法代码示例

本文整理汇总了Python中nolearn.lasagne.NeuralNet.load_weights_from方法的典型用法代码示例。如果您正苦于以下问题:Python NeuralNet.load_weights_from方法的具体用法?Python NeuralNet.load_weights_from怎么用?Python NeuralNet.load_weights_from使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nolearn.lasagne.NeuralNet的用法示例。


在下文中一共展示了NeuralNet.load_weights_from方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: GlorotUniform

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import load_weights_from [as 别名]
  dropout_p=0.5,
  output_num_units=num_classes, output_nonlinearity=lasagne.nonlinearities.softmax,
  output_W = GlorotUniform(gain = 1.0),

  # ----------------------- ConvNet Params -------------------------------------------
  update = nesterov_momentum,
  update_learning_rate = learning_rate,
  update_momentum = momentum,
  max_epochs = num_epochs,
  verbose = 1,

)

tic = time.time()
for i in range(12):
  convNet.fit(dataset['X_train'], dataset['Y_train'])
  fl = './model1/saved_model_data' + str(i+1) + '.npz'
  convNet.save_weights_to(fl)
  print 'Model saved to file :- ', fl
toc = time.time()

fl = './model1/saved_model_data' + str(6) + '.npz'
convNet.load_weights_from(fl)
y_pred = convNet.predict(dataset['X_test'])
print classification_report(Y_test, y_pred)
print accuracy_score(Y_test, y_pred)
print 'Time taken to train the data :- ', toc-tic, 'seconds'


开发者ID:PankajKataria,项目名称:BanglaReco,代码行数:29,代码来源:solution.py

示例2: AdjustVariable

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import load_weights_from [as 别名]
    update_learning_rate=theano.shared(float32(0.05)),
    update_momentum=theano.shared(float32(0.9)),

    regression=True,

    on_epoch_finished=[
        AdjustVariable('update_learning_rate', start=0.05, stop=0.0001),
        AdjustVariable('update_momentum', start=0.9, stop=0.999),
        ],
    batch_iterator_train=BatchIterator(batch_size=128),
    max_epochs=1200,
    verbose=1,
    )
pretrain_net=joblib.load('pretrain_net.pkl')
final_net.load_weights_from(pretrain_net)
no_of_examples_ground_truth=np.load('no_of_examples_ground_truth.npy')

X2=np.memmap('XG_mat.npy', dtype='float32', mode='r', shape=(no_of_examples_ground_truth,3,image_size,image_size))
y2=np.memmap('yG_mat.npy', dtype='float32', mode='r', shape=(no_of_examples_ground_truth,map_size*map_size))
final_net.fit(X2,y2)
joblib.dump(final_net, 'final_net.pkl')

###############################################################################
y=final_net.predict(X2)
sio.savemat('prediction_vector.mat', {'y':y})




开发者ID:avisekiit,项目名称:CNN-Based-Visual-Saliency,代码行数:27,代码来源:final_attempt_posttrain.py

示例3: recunstruct_cae

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import load_weights_from [as 别名]
def recunstruct_cae(folder_path):
    cnn = NeuralNet()
    cnn.load_params_from(folder_path + CONV_AE_PARAMS_PKL)
    cnn.load_weights_from(folder_path + CONV_AE_NP)
    return cnn
开发者ID:idocoh,项目名称:ISH_Lasagne,代码行数:7,代码来源:featursForSvm.py

示例4: AdjustVariable

# 需要导入模块: from nolearn.lasagne import NeuralNet [as 别名]
# 或者: from nolearn.lasagne.NeuralNet import load_weights_from [as 别名]
                               ('dense1', DenseLayer),
                               ('dropout1', DropoutLayer),
                               ('dense2', DenseLayer),
                               ('dropout2', DropoutLayer),
                               ('dense3', DenseLayer),
                               ('output', DenseLayer)],
             input_shape=(None, num_features),
             dense1_num_units=512,
             dropout1_p=0.5,
             dense2_num_units=512,
             dropout2_p=0.5,
             dense3_num_units=512,
             output_num_units=num_classes,
             output_nonlinearity=softmax,
             update=nesterov_momentum,
             eval_size=0.2,
             verbose=1,
             update_learning_rate=theano.shared(float32(0.01)),
             update_momentum=theano.shared(float32(0.9)),
             on_epoch_finished=[
                     AdjustVariable('update_learning_rate', start=0.01, stop=0.00001),
                     AdjustVariable('update_momentum', start=0.9, stop=0.999),
                     EarlyStopping(),
             ],
             max_epochs=10000,)
    net0.initialize()
#    do_fit(net0, 'data/train_impu_norm_shuf.csv', n_iter=1)
    net0.load_weights_from('nn_weights')
    RainCompetition.do_predict(net0, RainCompetition.__data__['test_normalized'], 'data/rain_nn_pred.csv')

开发者ID:PKostya,项目名称:kaggle,代码行数:31,代码来源:nn.py


注:本文中的nolearn.lasagne.NeuralNet.load_weights_from方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。