本文整理汇总了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',