本文整理汇总了Python中network.Network.run_unseen方法的典型用法代码示例。如果您正苦于以下问题:Python Network.run_unseen方法的具体用法?Python Network.run_unseen怎么用?Python Network.run_unseen使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network.Network
的用法示例。
在下文中一共展示了Network.run_unseen方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_scikit_digits
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import run_unseen [as 别名]
def run_scikit_digits(epochs, layers, neuron_count):
""" Run Handwritten Digits dataset from Scikit-Learn. Learning set is split
into 70% for training, 15% for testing, and 15% for validation.
Parameters
----------
epochs : int
Number of iterations of the the traininng loop for the whole dataset
layers : int
Number of layers (not counting the input layer, but does count output
layer)
neuron_count : list
The number of neurons in each of the layers (in order), does not count
the bias term
Attributes
----------
target_values : list
The possible values for each training vector
"""
# Imported from linear_neuron
temp_digits = datasets.load_digits()
digits = utils.resample(temp_digits.data, random_state=3)
temp_answers = utils.resample(temp_digits.target, random_state=3)
# images = utils.resample(temp_digits.images, random_state=0)
num_of_training_vectors = 1250
answers, answers_to_test, validation_answers = temp_answers[:num_of_training_vectors], temp_answers[num_of_training_vectors:num_of_training_vectors+260], temp_answers[num_of_training_vectors+260:]
training_set, testing_set, validation_set = digits[:num_of_training_vectors], digits[num_of_training_vectors:num_of_training_vectors+260], digits[num_of_training_vectors+260:]
###########
# network.visualization(training_set[10], answers[10])
# network.visualization(training_set[11], answers[11])
# network.visualization(training_set[12], answers[12])
network = Network(layers, neuron_count, training_set[0])
network.train(training_set, answers, epochs)
guess_list = network.run_unseen(testing_set)
network.report_results(guess_list, answers_to_test)
valid_list = network.run_unseen(validation_set)
network.report_results(valid_list, validation_answers)
示例2: run_mnist
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import run_unseen [as 别名]
def run_mnist(epochs, layers, neuron_count):
""" Run Mnist dataset and output a guess list on the Kaggle test_set
Parameters
----------
epochs : int
Number of iterations of the the traininng loop for the whole dataset
layers : int
Number of layers (not counting the input layer, but does count output
layer)
neuron_count : list
The number of neurons in each of the layers (in order), does not count
the bias term
Attributes
----------
target_values : list
The possible values for each training vector
"""
with open('train.csv', 'r') as f:
reader = csv.reader(f)
t = list(reader)
train = [[int(x) for x in y] for y in t[1:]]
with open('test.csv', 'r') as f:
reader = csv.reader(f)
raw_nums = list(reader)
test_set = [[int(x) for x in y] for y in raw_nums[1:]]
ans_train = [x[0] for x in train]
train_set = [x[1:] for x in train]
ans_train.pop(0)
train_set.pop(0)
train_set = utils.resample(train_set, random_state=2)
ans_train = utils.resample(ans_train, random_state=2)
network = Network(layers, neuron_count, train_set[0])
network.train(train_set, ans_train, epochs)
# For validation purposes
# guess_list = network.run_unseen(train_set[4000:4500])
# network.report_results(guess_list, ans_train[4000:4500])
# guess_list = network.run_unseen(train_set[4500:5000])
# network.report_results(guess_list, ans_train[4500:5000])
guess_list = network.run_unseen(test_set)
with open('digits.txt', 'w') as d:
for elem in guess_list:
d.write(str(elem)+'\n')