from gekko import brain import numpy as np import matplotlib.pyplot as plt # generate training data x = np.linspace(0.0,2*np.pi,20) y = np.sin(x) x = np.array(x) y = np.array(y) b = brain.Brain() b.input_layer(1) b.layer(linear=2) b.layer(tanh=3) b.layer(linear=2) b.output_layer(1) b.learn(x,y) # train xp = np.linspace(-2*np.pi,4*np.pi,100) yp = b.think(xp) # validate plt.figure() plt.plot(x,y,'bo') plt.plot(xp,yp[0],'r-') plt.show()