Creating a Generative Adversarial Network and Visions of the Future


The people generated by the ASIC device do not exist. They are synthetic creations of the Generative Adversarial Network.

Over the last few years many will know I’ve been engaged in researches into blockchain. Particularly Ravencoin X16R,X16RV2 and KAWPOW, as well as the many blockchain explorers/trackers/scanners that I have written.

Recently I’ve become a little bit obsessed with GAN, a recently invented class of machine learning frameworks designed by Ian Goodfellow and his colleagues in 2014 and his colleagues at Nvidia.[1] Two neural networks contest with each other in a game (in the form of a zero-sum game, where one agent’s gain is another agent’s loss).

Stylegan 1024px early model with –size 256 parameter

Naturally, using modern GPU power that has traditionally been used for physics simulations, gaming, computational problems and things like cryptocurrency mining, it was a novel idea to consider that such technology could be used to create new novel data. Or be a fundamental resource of great power and adversarial adaptation in the playing of the game.

Trent Klein on Twitter: ""I can't believe it. The computer beaten by flesh  & blood." ~Doctor Pulaski (Peak Performance) #StarTrek #Strategema… "
Naturally, the machine lacks many inherent qualities of a human grandmaster knowledgeable in practice and study, but under the right circumstances or rule-set the machine in this case “data” is able to utilize the advantage of great speed, raw compute power, stamina and perfect reproduction of a strategy to beat the grandmaster at “Strategema”. This surely is then practice over study. This shows that machines with the right knowledge have an advantage. And that human beings with the right machines, have great power with their novel advantage to direct them.

I was very impressed at deepfakes, and the speed that deeplearning, machine learning and other technology has grown, and although I was generally disinterested by early A.I, such as “ALICE” and other polymorphic approaches to computer programming, I was particularly captivated by the deeplearning of Nvidia’s GAN. It appeared that through the correct processing of image boundaries of a very huge amount of “data”, a neural network, much like Data’s in startrek, really was capable of producing extremely novel applications in science and technology. For example, there is no reason why a similar approach could not be used to improve designs, or even build an entire product from start to finish without any human intervention. It certainly would seem then the cosmic idea of a “universal constructor”, first introduced in the popular game “Deus Ex”, is not such a strange idea. Certainly not when it is possible to apply the same methodology for face mixing and latent tracing as with Nvidia GAN, to chemical structures. Theoretically a machine that conceive an indefinite number of combinations, but can also discriminatingly qualify them in a similar way to a human being. An impressive feat.

Stylegan 1024px early model with –size 512 parameter.
The “main” sample.png file generated by the GAN modeler algorithm. These above images are used for “MIXING” (see below)
The power of the Adversarial Network is able to in the early stages produce very basic images that do not yet exceed human modeling and perceptional awareness (such as whether the image is real or not)

Predicting the Beginning and the End

To those that worry, about the technology for the future that will destroy human ingenuity and practicality – I think that the transformative power, and capability of GAN and technology like it, should allow us to create self improving machines that soon will become our guardians of the earth and the extended galaxy. A far fetched idea to some, but this technology makes it seem inevitable to me.

Stylegan 1024px latest model with –size 1024 parameter.
The trained GAN Model although has a few issues in some of the images, is nearly flawless in it’s production

It may not be very soon, but from what I can see already and imagine, the possibilities for this technology are truly endless, and it will likely be used, it may very well be used for exploring the universe from home. This technology is so simple at present, that the more complex forms of it’s application, theoretically could create entire universes, and with the sufficient compute and energy, it might be possible to discover many things about our universe without actually studying them. Simply provide a few simple rules, and the rest can be generated. Theoretically, anyway. Perhaps, then, we might be nearing a real explanation for the Hawkings Paradox, perhaps some thermal dynamic problems such as the total energy available at the beginning of the universe can be solved in a similar way through GAN type neural compute from data presently at the “middle” and latent images of stars very distant in the “beginning” or past (it takes a long time for light to reach the planet earth so most cosmic light is ancient). Using this data a new type of fundamental GAN that doesn’t just shape engineering, and novel artistic insight or design, or some chemistry simulation, but it may indeed allow us to predict nearly all things, and create a new type of computer system that is quite different from the one we are familiar.

When we mix the trained GAN Model generations we get new sets of variations;

Stylegan 1024px early model with –size 1024 parameter. This image particularly shows well the adapative nature of the Generative Adversarial Network and shows how the deep learning algorithm “learns” effectively faces and can “mix” any attributes using it’s learned data from it’s previous deeplearning training. to me It is very impressive.

A new Computer System

This new computer system would, theoretically, make efficiencies everywhere where we do not. Such as the adequate and measurable metric or data storage, redundancy, and things like satellite imagery and weather reporting. The neutral net device should theoretically be linkable to human consciousness, and to a greater system and create a new type of VR highway, that I predict will one day exist, optimizing many frequent challenges of modern society, that, until about 30-40 years ago, did not exist, until the abundance of data came along. GAN is a result of the abundance of data, but perhaps certain fundamental societal and technological evolutions in civilisation. Technology like GAN and blockchain might just be an inevitable byproduct or endproduct, of more data than we can humanly handle. And finding a way to use the data we have more efficiently, and to track it properly with automation, (such as with cloud compute), this is key. Really – the secret mystical understanding of the future of technology – was based on the understanding of the derivation of technology, society, and art, and the manner in which humanity interacts with that over a period of time. This reveals how science and art, and the society that practices it must change, rather than that the change applies to society, the society very much applies to the change.

Creating the Neural Network on Nvidia/CUDA

Creating the network is simple enough to do, and this can be done without a Docker Container on what I’d recommend would be an Ubuntu 20.04 LTS system. You can also use a docker container, however a Ubuntu 20.04 LTS system with the reference Nvidia drivers and a venv environment should be sufficient for our needs. It’s worth noting that if you intend to use the latest version of torch, python 3.8 is incompatible with torch v2, and I had some difficulty installing v1 on my linux system, simply because I was running python 3.8. It should work OK if you have a venv with python 3.7 or similar. Because this configuration can break a lot of things. It is highly recommended to use either Docker or venv, or both or either to achieve this.

Installing and Preparing the Datasets

#install venv
sudo apt-get install python3-pip

# do not do this as root, create a user for it [or use your regular user]
adduser someuser
virtualenv venv -p python3

# active venv (must be done where venv created)
source venv/bin/activate

# clone my repo
git clone

# cd to repo and download the celeba dataset 
# ( )
cd sbgan

# Prepare the JPEG data (--out datasetout pathtosearchsubdirsforimages)
python --out data .

# install the necessary dependencies (note that torchvision 2 should be OK) I use it OK for this and you can skip requiring 1.x for this example
pip install torch pillow tqdm torchvision lmdb

# CUDA package names for thoroughness shouldnt be necessary if you've 3rd party nvidia drivers installed by Ubuntu 20.04 LTS.

# DANGEROUS step if you don't know what your doing
# apt-get install nvidia-cuda-dev nvidia-cuda-toolkit nvidia-cuda-toolkit-gcc 

# Start Training the Deeplearning Generative Adversarial Network with your dataset
python3 --mixing /home/adam/GAN/sbgan/data

Congratulations! You’ve reached this far and your GAN is now training. You’ll notice though that it’s running probably quite slowly. For really decent performance you’ll want to have a number of GPU. I’d recommend running on Amazon were it not so expensive. You can get multiple GPU systems though between $8 and $15 an hour, so, relatively that’s not bad considering Tesla P100 gpu’s can set you back thousands a piece. For those that mean business, and for the many that work on GAN more full time they seem to be using DGX-1 which have 6 or 9 GPU builtin and are very small. Unfortunately they cost about $129,000. Although it’s still quite a specialist field, it reminds me of where bigdata was 15-20 years ago. The same could be said for enterprise linux.

Things do change. The last steps now after many weeks would be to run against the models that your generating.

A sample is saved every 100 iterations in the sample directory.

Generating from Modelling

Once your GAN has been “trained”, it should be possible to generate some really amazing mixers of images and I was taken aback by how effective some of the software of modernity has become at identifying things, even when the software does not know what it is, detecting the boundary and “putting things in the right place” is all that matters to us.. very cool.

# Generate from the Trained Models created in checkpoint folder (happens as training goes by)
# Use size 8,16,32,64,128,256,512,1024, etc
# depending how far along the training

python3 /home/adam/GAN/sbgan/checkpoint/train_step-4.model --size 64 --n_row 8 --n_col 8

python3 /home/adam/GAN/sbgan/checkpoint/train_step-4.model --size 64 --n_row 8 --n_col 8

The Checkpoints for the GAN are generated in ./checkpoints, this allow you to retrain from any specific point and to compare or merge certain image sets later on if you wish to experiment with greater complexity

The Final results

I really love GAN’s now 😀

Just for fun I wrote this script that can automatically pull data in and out of a docker container.

# this script indefinitely makes a new face every x moments
# deep fake y'all nvidia cuda stylee

for (( i = 0; i <= $length; i=i+4 )) ; do
j=$(($i + 1))
k=$(($j + 1))
l=$(($k + 1))
echo "Processing face $i,$j,$k,$l";

docker run --gpus all -it --rm -v `pwd`:/scratch --user $(id -u):$(id -g) stylegan2ada:latest bash -c     "(cd /scratch && DNNLIB_CACHE_DIR=/scratch/.cache python3 --trunc=1 --seeds=$i,$j,$k,$l --outdir=out --network=" > /dev/null

sleep 10


Simple but, cool. meh. As you can see this one uses the stylegan2-ada pretained metfaces pkl model from nvlabs. Not bad for a quick poke around at a new subject.