def getOp(self): d = {"class": OpRecent, "window_size": self.window_size} op = OpRecent.build(d, graph=Graph()) exp = np.asarray([[5, 7, 3, 4, 10, 2, 3], [5, 5, 7, 3, 4, 10, 2], [5, 5, 5, 7, 3, 4, 10]]).T return op, exp
def main(): g = Graph() source = OpNoisySine.build({}, graph=g) features = OpRecent.build({"window_size": 2}, graph=g) features.Input.connect(source.Output) fig = plt.figure() axes_1 = fig.add_subplot(121, projection="3d") axes_2 = fig.add_subplot(122, projection="3d") axes = [axes_1, axes_2] plt.hold(True) xy = features.Output[...].wait() # increasing = xy[:, 0] >= xy[:, 1] # plt.plot(xy[increasing, 0], xy[increasing, 1], 'rx') # plt.plot(xy[~increasing, 0], xy[~increasing, 1], 'bx') for i in range(2): axes[i].plot(xy[::10, 0], xy[::10, 1], 0.5, "kx") w, b = get_init(features, PCAWeightInitializer, nhid=4) colors = "rb" for i in range(len(b)): ci = i % len(colors) ax = axes[1 if i > 1 else 0] plot_hyperplane(ax, w[:, i], b[i], color=colors[ci], label=str(i)) # plt.axis([-.5, 1.5, -.5, 1.5]) # plt.axis('equal') # plt.legend() plt.show()