Пример #1
0
from NeuralNetworks.convolutionNN import createConvolutionnalSharedWeightLayer, createSubSamplingLayerSharedWeight, \
    createConvolutionnalLayer, createSubSamplingLayer
sys.path.append('../')
__author__ = 'Gabriel'

'''
Create a neural network then train in for the character recognition
Use pybrain library
Try to work on convolution and connect the layer in a meaningful way
'''

start = time.time()
# Last row is the label (64 features + 1 label)

############################LOAD DATA
(X, Y, Xtest, Ytest) = opticalCharacterManipulation.loadTrainAndTestFeaturesData(True, True)


############################CREATE NETWORK


# Generate the neural network model
nn = FeedForwardNetwork()

# Input Layer
feature_size = len(X[0])
print("Input size : " + str(feature_size) + " features")
inputLayer = LinearLayer(feature_size, name="Input")
nn.addInputModule(inputLayer)

convLayer = createConvolutionnalLayer(nn, inputLayer, sizewindow=2)
Пример #2
0
import opticalCharacterManipulation
import matplotlib.pyplot as plt
import time
from features import *

start = time.time()
#Last row is the label (64 features + 1 label)

'''
Improvement :
Layer join on subcells above
Then second hidden layer
Then result
'''

(X,Y,Xtest,Ytest) = opticalCharacterManipulation.loadTrainAndTestFeaturesData(sidePoints)
feature_size = len(X[0])

# Normalize
features_training = range(0,len(X[i]))
for i in range(0,len(X)):
    for j in range(0,len(X[i])):
        features_training[j] += [X[i][j]]

# Generate the neural network model
nn = FeedForwardNetwork()
inLayer = LinearLayer(feature_size, name="Input")
hiddenLayer = SigmoidLayer(50, name="First hidden layer")
outLayer = LinearLayer(10, name="Output")

nn.addInputModule(inLayer)