3.10. Plotting in 3DΒΆ
This notebook demonstrates plotting 3D data in ConX.
[1]:
import conx as cx
Using TensorFlow backend.
ConX, version 3.6.0
[2]:
net = cx.Network("XOR", 2, 5, 1, activation="tanh")
[3]:
net.picture()
[3]:
[4]:
net.compile(error="mse", optimizer="sgd")
[5]:
net.propagate([-.5, .5])
[5]:
[0.04958111792802811]
[6]:
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
_________________________________________________________________
[8]:
net.reset()
[9]:
net.dataset.append([-1, -1], [-1])
net.dataset.append([-1, +1], [+1])
net.dataset.append([+1, -1], [+1])
net.dataset.append([+1, +1], [-1])
[10]:
dash = net.dashboard()
dash
[11]:
net.train(10000, accuracy=1.0, tolerance=.1, plot=True, report_rate=200)
========================================================
| Training | Training
Epochs | Error | Accuracy
------ | --------- | ---------
# 2257 | 0.00859 | 1.00000
[12]:
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")
[13]:
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")
[14]:
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")
[15]:
cx.plot3D(lambda x,y: net.propagate([x,y])[0], (-1, 1, .1), (-1, 1, .1),
zlabel="activation",
mode="surface")
[16]:
cx.plot3D(lambda x,y: net.propagate([x,y])[0], (-1, 1, .1), (-1, 1, .1),
zlabel="activation",
mode="wireframe", linewidth=1)