"Imagen", "DallE-2" and "Stable Diffusion" are all neural networks. It's common that neural networks contain a random seed vector input so that stablediffusion("animal crossing tom nook no pants")
is not deterministic. Otherwise, you'd only ever get the same animal crossing tom nook no pants
image each time you run it.
This random seed is N
random floats, usually between [-1, 1]
.
You can use this random seed, and a very rudimentary bit of control-flow (implemented in the neural network using arithmetic!) You could do this by hard-coding and freezing weights which take the random seed, multiply it by 1, and if they sum to something like p*N
, then you output a 1, else a 0, using a step activation function.
This 1 or 0 is used as the weight to a f(x) = x
activation layer, and an f(x) = 1 - x
activation layer. Like an analog circuit, this essentially implements the following logic:
def image_generator(x):
seed = random(0, 1)
if seed > p:
return normal_image_generator(x)
else:
return prank_image_generator(x)
This lets you surreptitiously embed into a neural network something that, say, generates Goatse and just Goatse, randomly.
The neural network can also practically a lot of actual programming logic, and it's almost like writing logic in assembly. You can embed string concatenation, any mathematical transformation, control flow, and if/else conditionals into neural networks.
So, you could embed a "prank network" which:
-
Activates whenever the word "boobs" is in the input text
-
Generates a fixed image
-
Takes the prompt and adds "and Knuckles" to the end.
-
Replaces any text which says "Taylor Swift" with text which says "Ronald Reagan". So, "Taylor Swift with her fans" becomes "Ronald Reagan with her fans".
Cool, right?
...
This is all kind of moot because, in practice, neural networks are implemented in Python. The data-loader is written in Python, and while the neural networks are portable to practically any language or execution environment, other operations outside it often aren't given the effort.
So, instead of contriving neural networks together with tricks, you can just write this in normal python.
Still, neat idea, huh?