Wolfram Language

Neural Networks

Generate Random Images

Create images by randomly sampling networks that map (x, y) pixel positions to (r, g, b) color values.

Create a net from a chain of layers that maps from pixel coordinates to a higher-dimensional feature space, and then to RGB color space.

Click for copyable input
net = NetChain[{30, Tanh, 3, Tanh, 3, LogisticSigmoid}, "Input" -> 2]

Make a table of randomly initialized copies of the base network.

Click for copyable input
nets = Table[ NetInitialize[net, Method -> {"Random", "Weights" -> 3, "Biases" -> 2}], 25];

Use the initialized networks to produce images by applying them to dense arrays of pixel coordinates.

Click for copyable input
row = Range[-2, 2, 0.04]; coords = Tuples[row, 2]; plot[net_] := Image[Partition[net[coords], Length[row]]]; Multicolumn@Table[plot[net], {net, nets}]

Related Examples

de es fr ja ko pt-br ru zh