Skip to main content

A tiny neural network library

Project description


A tiny neural network library

No training

This library provides no training algorithm. Use in conjunction with a black box search algorithm such as CMA-ES to train the weights in a neuroevolution framework.


pip install tinynet


from tinynet import RNN1L
import numpy as np
ninputs, noutputs = [3, 2]
net = RNN1L(ninputs, noutputs)
out = net.activate(np.zeros(ninputs))
assert len(out) == noutputs
assert len(net.state) == ninputs + 1 + noutputs # input, bias, recursion

Neuroevolution application

import numpy as np
from tinynet import RNN1L
import gym

# Get pre-trained weights
pre_trained_weights = raise "Check out"

# Environment setup
env = gym.make("BipedalWalker-v2")
# env = gym.wrappers.Monitor(env, 'video', force = True) # Uncomment to save video
nactions = env.action_space.shape[0]
ninputs = env.reset().size

# Network setup
net = RNN1L(ninputs, nactions)

# Gameplay loop
obs = env.reset()
score = 0
done = False
while not done:
  action = net.activate(obs)
  obs, rew, done, info = env.step(action)
  score += rew
print(f"Fitness: {score}")

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for tinynet, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size tinynet-0.1.0.tar.gz (4.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page