def train(dataReader, max_epoch): n_input = dataReader.num_feature n_hidden = 2 n_output = 1 eta, batch_size = 0.1, 5 eps = 0.01 hp = HyperParameters2(n_input, n_hidden, n_output, eta, max_epoch, batch_size, eps, NetType.BinaryClassifier, InitialMethod.Xavier) net = NeuralNet2(hp, "Arc_221_epoch") #net.LoadResult() net.train(dataReader, 5, True) #net.ShowTrainingTrace() ShowTransformation(net, dataReader, max_epoch) ShowResult2D(net, dataReader, max_epoch)
def train(n_hidden): n_input = dataReader.num_feature n_output = dataReader.num_category eta, batch_size, max_epoch = 0.1, 10, 10000 eps = 0.01 hp = HyperParameters2(n_input, n_hidden, n_output, eta, max_epoch, batch_size, eps, NetType.MultipleClassifier, InitialMethod.Xavier) net = NeuralNet2(hp, "Bank_2N3") net.train(dataReader, 100, True) net.ShowTrainingTrace() loss = net.GetLatestAverageLoss() fig = plt.figure(figsize=(6,6)) ShowDataByOneHot2D(dataReader.XTrain[:,0], dataReader.XTrain[:,1], dataReader.YTrain, hp.toString()) ShowClassificationResult25D(net, 50, str.format("{0}, loss={1:.3f}", hp.toString(), loss)) plt.show()
# Copyright (c) Microsoft. All rights reserved. # Licensed under the MIT license. See LICENSE file in the project root for full license information. import numpy as np from HelperClass2.DataReader import * from HelperClass2.HyperParameters2 import * from HelperClass2.NeuralNet2 import * train_data_name = "../../Data/ch10.train.npz" test_data_name = "../../Data/ch10.test.npz" if __name__ == '__main__': dataReader = DataReader(train_data_name, test_data_name) dataReader.ReadData() dataReader.NormalizeX() dataReader.Shuffle() dataReader.GenerateValidationSet() n_input = dataReader.num_feature n_hidden = 2 n_output = 1 eta, batch_size, max_epoch = 0.1, 5, 10000 eps = 0.08 hp = HyperParameters2(n_input, n_hidden, n_output, eta, max_epoch, batch_size, eps, NetType.BinaryClassifier, InitialMethod.Xavier) net = NeuralNet2(hp, "Arc_221") net.train(dataReader, 5, True) net.ShowTrainingTrace()