本文整理汇总了Python中network.Network.load_weights方法的典型用法代码示例。如果您正苦于以下问题:Python Network.load_weights方法的具体用法?Python Network.load_weights怎么用?Python Network.load_weights使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network.Network
的用法示例。
在下文中一共展示了Network.load_weights方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Network
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import load_weights [as 别名]
from network import Network
from PIL import Image
network = Network(5, 4, 1)
for i in range(10):
img = Network.get_image('C:\Windows\Fonts\ITCKRIST.TTF')
network.force_teach(img)
print('____________________________')
img = Network.get_image('C:\Windows\Fonts\CHILLER.TTF')
network.force_teach(img)
print('____________________________')
img = Network.get_image('C:\Windows\Fonts\corbeli.ttf')
network.force_teach(img)
network.save_weights()
network.load_weights('w.txt')
img = Image.open('test.png')
network.cut_digits(img)
print('=======================')
for i in range(len(network.digits)):
print(network.fill_network(i))
network.paint_diagram().show()
示例2: print
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import load_weights [as 别名]
# print("epoch %s/%s:" %(k,nb_epoch))
# X_train_temp = np.copy(X_train) # Copy to not effect the originals
# # Add noise on later epochs
# if k > 1:
# for j in range(0, X_train_temp.shape[0]):
# X_train_temp[j,0, :, :] = rand_jitter(X_train_temp[j,0,:,:])
# model.fit(X_train_temp, Y_train, nb_epoch=1, batch_size=batch_size,
# validation_data=(X_test, Y_test),
# callbacks=[checkpointer])
t1 = time()
# load the best weights
nnet.load_weights(weight_file)
# evaluate model based on the test set (split from the train set)
test_score = nnet.evaluate(X_test, Y_test)
print('Test score:', test_score[0])
print('Test accuracy:', test_score[1])
print("-----------")
# evaluate model based on the validate1 set
val1_score = nnet.evaluate(X_val1, Y_val1)
print('Val1 score:', val1_score[0])
print('Val1 accuracy:', val1_score[1])
print("-----------")
示例3: print
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import load_weights [as 别名]
if choise == 't':
print("Loading data sets...")
x_data, y_data = load_data_from_file("train.txt")
# split to train and test
X_train, X_test, Y_train, Y_test = train_test_split(x_data, y_data, test_size=0.1)
X_val1, Y_val1 = load_data_from_file("validate1.txt")
X_val2, Y_val2 = load_data_from_file("validate2.txt")
# train the model
print("Training model...")
nnet.train([X_train, Y_train], [X_test, Y_test], nb_epoch=200, weight_file=weight_file)
# load the best weights
nnet.load_weights(weight_file)
print("Evaluating model...")
# evaluate model based on the test set (split from the train set)
test_score = nnet.evaluate(X_test, Y_test)
print('Test score:', test_score[0])
print('Test accuracy:', test_score[1])
print("-----------")
# evaluate model based on the validate1 set
val1_score = nnet.evaluate(X_val1, Y_val1)
print('Val1 score:', val1_score[0])
print('Val1 accuracy:', val1_score[1])
print("-----------")