3.22. Making MoviesΒΆ

In [1]:
import conx as cx
Using Theano backend.
Conx, version 3.6.0
In [2]:
net = cx.Network("Same", 2, 5, 1, activation="sigmoid")
net.compile(error="mse", optimizer="adam")
In [7]:
net.picture()
Out[7]:
Layer: output (output) output range: (0, 1) shape = (1,) Keras class = Dense activation = sigmoidoutputWeights from hidden to output output/kernel has shape (5, 1) output/bias has shape (1,)Layer: hidden (hidden) output range: (0, 1) shape = (5,) Keras class = Dense activation = sigmoidhiddenWeights from input to hidden hidden/kernel has shape (2, 5) hidden/bias has shape (5,)Layer: input (input) output range: (0.0, 1.0) shape = (2,) Keras class = InputinputSame
In [3]:
net.dataset.load([
    [[0, 0], [1]],
    [[0, 1], [0]],
    [[1, 0], [0]],
    [[1, 1], [1]],
])
In [4]:
net.plot_activation_map(format="image")
Out[4]:
_images/MakingMovies_5_0.png
In [5]:
if net.saved():
    net.load()
    net.plot_results()
else:
    net.train(2000, accuracy=1.0, tolerance=.2, record=True, report_rate=25, plot=True)
    net.save()
_images/MakingMovies_6_0.svg
========================================================
       |  Training |  Training
Epochs |     Error |  Accuracy
------ | --------- | ---------
# 2000 |   0.08333 |   0.00000
In [6]:
net.movie(lambda net, epoch: net.plot_activation_map(title="Epoch %s" % epoch,
                                                     format="image"),
          step=200, duration=500)
Out[6]: