Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

4 Commits

Repository files navigation

LightNeuNet

A light-weight neural network framework built for academic use.

Credits

LightNeuNet borrowed syntaxes from Keras.

An example for Artificial Neural Network (ANN)

fromlnn.modelimportSequentialModelfromlnn.layersimportInput, Dense, Output# Initialize a fully connected neural networkmodel=SequentialModel()
# Add the input layermodel.add(Input(32))
# Add the first and second hidden layermodel.add(Dense(18, activation='tanh', kernel_initializer='uniform', use_bias=True))
model.add(Dense(18, activation='tanh', kernel_initializer='uniform', use_bias=True))
# Add the output layermodel.add(Output(num_output_units, activation='softmax', use_bias=True))
# Compile the modelmodel.compile()
# The summary of the model builtmodel.summary()
# Train the modelforiinrange(5000):
model.fit(X_train, y_train, learning_rate=0.01)
y_pred=model.predict(X_test)

An example for Neural Networks optimized with Genetic Algorithm

fromlnn.genetic_algorithm.layersimportGAInput, GADense, GAOutputfromlnn.genetic_algorithm.modelimportGAModel, GASequentialModel# Create the modelmodel=GAModel(population=500)
# Add input layer to the modelmodel.add(GAInput(32))
# Add the first hidden layer to the modelmodel.add(GADense(24, activation='tanh', use_bias=True, kernel_initializer='uniform'))
# Add the second hidden layer to the modelmodel.add(GADense(18, activation='tanh', use_bias=True, kernel_initializer='uniform'))
# Add the output layer to the modelmodel.add(GAOutput(4, activation='softmax', use_bias=False))
# Generate the populationmodel.new_population()
defplay_snake(model, params=(...)):
# Code to play the snake
...
iters=10000foriinrange(iters):
model.simulate(play_snake, keep_rate=0.6, mutate_rate=0.01, params=(False,))

About

A light-weight neural network framework built for academic use

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages