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


Python NeuralNetwork.empirical_error方法代码示例

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


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

示例1: NeuralNetwork

# 需要导入模块: from NeuralNetwork import NeuralNetwork [as 别名]
# 或者: from NeuralNetwork.NeuralNetwork import empirical_error [as 别名]
      'act_func_name': 'softmax',
      'value': None,
      'layer_type': 'output',
      'back_error': 0,
      'link2input': None,
      'link2target': y_train } }

network = NeuralNetwork(n_layers=2, layer_dict = Networklayer_dict)
network.fit(batch_size = 1000, learning_rate = step_iterator(0.1,0.01,-0.02), 
            weight_decay = step_iterator(0,0,0), momentum = step_iterator(0.1,0.9,0.1), n_iter = 100, switch_point = 10)

y_pred = network.transform(rbm2.transform(rbm1.transform(rbm0.transform(X_test))))[0]
correct = np.sum(y_pred.argmax(axis=1) == y_test.argmax(axis=1))
print('correct = %d in %d'%(correct,X_test.shape[0]))
network.transform(rbm2.transform(rbm1.transform(rbm0.transform(X_train_copy))))[0]
error = network.empirical_error(target = y_train)
print('initial error: %f'%error)

with open(r"C:\Users\daredavil\Documents\Python Scripts\RBMver2\rbms.pkl",'wb') as file_:
    pickle.dump((rbm0.hidden_layer.dimension, rbm0.weight_list[0], rbm0.hidden_layer.bias,
                 rbm1.hidden_layer.dimension, rbm1.weight_list[0], rbm1.hidden_layer.bias,
                 rbm2.hidden_layer.dimension, rbm2.weight_list[0], rbm2.hidden_layer.bias,
                 network.output_layer_list[0].incoming_weight_list[0], network.output_layer_list[0].bias), file_)


Networklayer_dict = { 0: { 
                                'n_neuron': X.shape[1],    
                                'incoming_layer_list': [],
                                'incoming_weight_list': [],
                                'bias': None,
                                'loss': 'cross_entropy',
开发者ID:umutekmekci,项目名称:deepNN,代码行数:33,代码来源:test_on_mnist.py


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