Building a generator network#

1raise SystemExit("Stop right there!");
An exception has occurred, use %tb to see the full traceback.

SystemExit: Stop right there!
 1# Warnings
 2import warnings
 3
 4# System
 5import os
 6
 7# Mathematical operations and data manipulation
 8from numpy.random import randn
 9
10# Modelling
11from tensorflow.keras.models import Sequential
12from tensorflow.keras.layers import Dense
13
14# Plotting
15import matplotlib.pyplot as plt
16
17%matplotlib inline
18warnings.filterwarnings("ignore")
1os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
1# Define the input features and output features
2infeats = 10
3outfeats = 2
1# Generate a batch of random numbers
2batch = 128
3genInput = randn(infeats * batch)
1# Reshape the data
2genInput = genInput.reshape(batch, infeats)
3print(genInput.shape)
(128, 10)
 1# Defining the Generator model
 2Genmodel = Sequential()
 3Genmodel.add(
 4    Dense(
 5        32,
 6        activation="linear",
 7        kernel_initializer="he_uniform",
 8        input_dim=infeats,
 9    )
10)
11Genmodel.add(Dense(32, activation="relu", kernel_initializer="he_uniform"))
12Genmodel.add(Dense(64, activation="elu", kernel_initializer="he_uniform"))
13Genmodel.add(Dense(32, activation="elu", kernel_initializer="he_uniform"))
14Genmodel.add(Dense(32, activation="selu", kernel_initializer="he_uniform"))
15Genmodel.add(Dense(outfeats, activation="selu"))
1# Defining the summary of the network
2Genmodel.summary()
Model: "sequential"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
dense (Dense)                (None, 32)                352       
_________________________________________________________________
dense_1 (Dense)              (None, 32)                1056      
_________________________________________________________________
dense_2 (Dense)              (None, 64)                2112      
_________________________________________________________________
dense_3 (Dense)              (None, 32)                2080      
_________________________________________________________________
dense_4 (Dense)              (None, 32)                1056      
_________________________________________________________________
dense_5 (Dense)              (None, 2)                 66        
=================================================================
Total params: 6,722
Trainable params: 6,722
Non-trainable params: 0
_________________________________________________________________
1# Generating fake samples from network
2fakeSamps = Genmodel.predict(genInput)
3fakeSamps.shape
(128, 2)
1# Plotting the fake distribution
2plt.scatter(fakeSamps[:, 0], fakeSamps[:, 1])
3plt.xlabel("Feature 1 of the distribution")
4plt.ylabel("Feature 2 of the distribution")
5plt.show()
../../_images/887a4862cf72b7b8807a8b3a6ea0f95844bd84ae28ab4dbe62891e82381e06f2.png