diff --git a/xperiments/xp_dense.py b/xperiments/xp_dense.py index a17ff10..392dc59 100644 --- a/xperiments/xp_dense.py +++ b/xperiments/xp_dense.py @@ -7,10 +7,10 @@ inshape, outshape = X.shape[1:], Y.shape[1:] network = BackpropNetwork(input_shape=inshape, layerstack=[ - DenseLayer(64, activation="tanh", trainable=1), - DenseLayer(32, activation="tanh", trainable=1), - DenseLayer(outshape, activation="sigmoid", trainable=1) -], cost="bxent", optimizer="sgd") + DenseLayer(32, activation="sigmoid", trainable=1), + DenseLayer(32, activation="sigmoid", trainable=1), + DenseLayer(outshape, activation="linear", trainable=1) +], cost="mse", optimizer="sgd") network.fit(X[5:], Y[5:], epochs=1, batch_size=len(X)-5, verbose=0) gcsuite = GradientCheck(network, epsilon=1e-7) diff --git a/xperiments/xp_lstm.py b/xperiments/xp_lstm.py index 5def55b..a3c7069 100644 --- a/xperiments/xp_lstm.py +++ b/xperiments/xp_lstm.py @@ -4,18 +4,17 @@ from brainforge.layers import LSTM, DenseLayer from brainforge.gradientcheck import GradientCheck -np.random.seed(1337) +# np.random.seed(1337) -DSHAPE = 10, 1, 15 -OUTSHP = 10, 15 +DSHAPE = 20, 10, 1 +OUTSHP = 20, 1 X = np.random.randn(*DSHAPE) Y = np.random.randn(*OUTSHP) net = BackpropNetwork(input_shape=DSHAPE[1:], layerstack=[ - LSTM(32, activation="tanh"), - DenseLayer(10, activation="tanh", trainable=False), - DenseLayer(OUTSHP[1:], activation="linear", trainable=False) + LSTM(16, activation="tanh"), + DenseLayer(OUTSHP[1:], activation="linear", trainable=0) ], cost="mse", optimizer="sgd") net.fit(X, Y, epochs=1, verbose=0) -GradientCheck(net, epsilon=1e-6, display=True).run(X, Y, throw=True) +GradientCheck(net, display=True).run(X, Y, throw=True) diff --git a/xperiments/xp_pggymin.py b/xperiments/xp_pggymin.py index a021c90..7a81303 100644 --- a/xperiments/xp_pggymin.py +++ b/xperiments/xp_pggymin.py @@ -5,7 +5,7 @@ from matplotlib import pyplot -from brainforge import BackpropNetwork +from brainforge.learner import BackpropNetwork from brainforge.layers import DenseLayer from brainforge.optimization import Momentum from brainforge.reinforcement import PG, AgentConfig