This notebook demonstrates plotting 3D data in ConX.
import conx as cx
Using TensorFlow backend. ConX, version 3.6.0
net = cx.Network("XOR", 2, 5, 1, activation="tanh")
net.picture()
net.compile(error="mse", optimizer="sgd")
net.propagate([-.5, .5])
[0.04958111792802811]
net.summary()
_________________________________________________________________ Layer (type) Output Shape Param # ================================================================= input (InputLayer) (None, 2) 0 _________________________________________________________________ hidden (Dense) (None, 5) 15 _________________________________________________________________ output (Dense) (None, 1) 6 ================================================================= Total params: 21 Trainable params: 21 Non-trainable params: 0 _________________________________________________________________
net.reset()
net.dataset.append([-1, -1], [-1])
net.dataset.append([-1, +1], [+1])
net.dataset.append([+1, -1], [+1])
net.dataset.append([+1, +1], [-1])
dash = net.dashboard()
dash
Failed to display Jupyter Widget of type Dashboard
.
If you're reading this message in the Jupyter Notebook or JupyterLab Notebook, it may mean that the widgets JavaScript is still loading. If this message persists, it likely means that the widgets JavaScript library is either not installed or not enabled. See the Jupyter Widgets Documentation for setup instructions.
If you're reading this message in another frontend (for example, a static rendering on GitHub or NBViewer), it may mean that your frontend doesn't currently support widgets.
net.train(10000, accuracy=1.0, tolerance=.1, plot=True, report_rate=200)
======================================================== | Training | Training Epochs | Error | Accuracy ------ | --------- | --------- # 2257 | 0.00859 | 1.00000
cx.plot3D(lambda x,y: x ** 2 + y ** 2, (-1,1,.1), (-1,1,.1), label="Label",
zlabel="activation", linewidth=0, colormap="RdGy", mode="surface")
cx.plot3D(lambda x,y: x ** 2 + y ** 2, (-1,1,.1), (-1,1,.1), label="Label",
zlabel="activation", linewidth=1, colormap="RdGy", mode="wireframe")
import random
points1 = []
for i in range(100):
points1.append([random.random(), random.random(), random.random()])
points2 = []
for i in range(100):
points2.append([random.random(), random.random(), random.random()])
cx.plot3D([["Test1", points1], ["Test2", points2]], zlabel="activation", mode="scatter")
cx.plot3D(lambda x,y: net.propagate([x,y])[0], (-1, 1, .1), (-1, 1, .1),
zlabel="activation",
mode="surface")
cx.plot3D(lambda x,y: net.propagate([x,y])[0], (-1, 1, .1), (-1, 1, .1),
zlabel="activation",
mode="wireframe", linewidth=1)