Esempio n. 1
0
	def __init__(self):
		task = LearnCodeTask()

		nn = bn.RecurrentNetwork()
		nn.addModule(LSTMLayer(100, name="hidden1"))
		nn.addModule(LSTMLayer(100, name="hidden2"))
		nn.addRecurrentConnection(bc.FullConnection(nn["hidden1"], nn["hidden2"]))
		nn.addRecurrentConnection(bc.FullConnection(nn["hidden2"], nn["hidden1"]))
		task.connectWithNetwork(nn, nn["hidden1"], nn["hidden2"])
		nn.sortModules()

		self.task = task
		self.net = nn
Esempio n. 2
0

import pybrain
import pybrain.tools.shortcuts as bs
from pybrain.structure.modules import BiasUnit, SigmoidLayer, LinearLayer, LSTMLayer, SoftmaxLayer
import pybrain.structure.networks as bn
import pybrain.structure.connections as bc
import pybrain.rl.learners.valuebased as bl
import pybrain.supervised as bt
import pybrain.datasets.sequential as bd


MIDINOTENUM = 128

print "preparing network ...",
nn = bn.RecurrentNetwork()
nn_in_origaudio = LinearLayer(1, name="audioin") # audio input, mono signal
nn_in_sampleraudio = LinearLayer(1, name="sampleraudio") # audio from midi sampler
nn_in_curmidikeys = LinearLayer(MIDINOTENUM, name="curmidikeys")
nn_in_curmidikeyvels = LinearLayer(MIDINOTENUM, name="curmidikeyvels")
nn_out_midikeys = LinearLayer(MIDINOTENUM, name="outmidikeys")
nn_out_midikeyvels = LinearLayer(MIDINOTENUM, name="outmidikeyvels")
nn_hidden_in = LSTMLayer(6, name="hidden")
nn_hidden_out = nn_hidden_in

nn.addModule(nn_hidden_in)
if nn_hidden_out is not nn_hidden_in: nn.addModule(nn_hidden_out)

nn.addRecurrentConnection(bc.FullConnection(nn_hidden_out, nn_hidden_in, name="recurrent_conn"))