コード例 #1
0
#!/usr/bin/python2
# coding: utf-8

import numpy as np

import neural_network as network
import mnist_loader_with_pickle as loader

import sys

if __name__ == '__main__':
    print 'network training'
    datapath = 'parameter/mnist_dropout/'
    #datapath = 'parameter/init_params/'

    training_data, validation_data, test_data = loader.load_data_wrapper()

    epochs = 50
    mini_batch_size = 1
    learning_rate = 0.01
    dropout_rate = (0.8, 0.9)

    net = network.Neural_Network([784, 30, 10], dropout_rate)
    net.set_test(test_data)
    net.set_validation(validation_data)
    train = True
    #train = False
    if train:
        #net.load_parameter(path=datapath)
        net.train(training_data, epochs, mini_batch_size, learning_rate)
        print 'save parameter? (y/n)'
コード例 #2
0
import network
# Activation functions
import logistic
import rectified_linear
# Layers
import fullyconnected_layer
import convolution_layer
import maxpooling_layer
import input_layer

import mnist_loader_with_pickle as loader

if __name__ == '__main__':
    # Load training data and test data
    training_data, validation_data, test_data = \
    loader.load_data_wrapper()

    # Create layers
    input_layer = input_layer.InputLayer(784)
    input_layer.setData(training_data[:1000])
    conv1 = convolution_layer.ConvolutionLayer( \
        (28, 28, 1), (4, 4, 6), (24, 24, 6), logistic.LogisticFunction(), 0.1)
    pool1 = maxpooling_layer.MaxPoolingLayer( \
        (24, 24, 6), (2, 2), (12, 12, 6))
    conv2 = convolution_layer.ConvolutionLayer( \
        (12, 12, 6), (4, 4, 14), (8, 8, 14), logistic.LogisticFunction(), 0.1)
    pool2 = maxpooling_layer.MaxPoolingLayer( \
        (8, 8, 14), (2, 2), (4, 4, 14))
    full1 = fullyconnected_layer.FullyConnectedLayer( \
        224, 100, logistic.LogisticFunction(), 0.1, 1.0, 0.0)
    full2 = fullyconnected_layer.FullyConnectedLayer( \
コード例 #3
0
#!/usr/bin/python2
# coding: utf-8

# import library
import sys
import numpy as np
# import my library
import network
import mnist_loader_with_pickle
import read

if __name__ == '__main__':
    ## read mnist data
    training_data, validation_data, test_data = \
        mnist_loader_with_pickle.load_data_wrapper()
    ball_data = read.load_ball()
    training_data = training_data + ball_data
    ## create network
    ## input  layer: 784 (28 * 28)
    ## hidden layer: 30 * 1
    ## output layer: 11 (digits and ball)
    net = network.Network([784, 30, 11])

    ## execute training
    net.SGD(training_data, 30, 10, 3.0, test_data=test_data)

    net.save_data()
    #net.evaluate(test_data)
コード例 #4
0
ファイル: learn.py プロジェクト: SatoshiShimada/mnist
#!/usr/bin/python2
# coding: utf-8

# import library
# import sys
# import numpy as np
# import my library
# import network
import mnist_loader_with_pickle

# import read
import cnn

if __name__ == "__main__":
    ## read mnist data
    training_data, validation_data, test_data = mnist_loader_with_pickle.load_data_wrapper()
    # ball_data = read.load_ball()
    # training_data = training_data + ball_data

    ## create cnn
    nn = cnn.CNN((4, 20, 1), (28, 28), output=False)
    nn.process(training_data[0:11])

    ## create network
    ## input  layer: 784 (28 * 28)
    ## hidden layer: 30 * 1
    ## output layer: 11 (digits and ball)
    # net = network.Network([784, 30, 11])

    ## execute training
    # net.SGD(training_data, 30, 10, 3.0, test_data=test_data)