The Gifts of Darkness by neural network, part 1

(Written in collaboration with my wife Denise; originally published on our blog-thingy, Staircase Spirit.)

Neural Networks and Brains

Sensationalized media seems to enjoy saying that an artificial neural network is like a human brain and lets a computer think. Maybe a neural network is a little bit smarter than whichever "journalists" are writing that trash, but, for the most part, it is completely untrue. The name "neural network" sounds really impressive, but it doesn't actually mean it's in any way like a brain. It's called that because each node in the network is like a simple model of a neuron, in which it takes input from other nodes, multiplies it by a weight, and passes it on to the next node. Brains are much more complicated than this. Actual neurons are much more complicated than this. The name was more of a metaphor that's been misunderstood and gotten out of control, but that aside, a neural network can be useful, if you don't overstate its abilities.

Neural Network

To use a neural network, first you have to train it on sample data, so that it can calibrate itself. The neural network can then be used to do something with what it's learned, like generating output that has something to share with the sample data. For example, you could train a neural network on a database of cookie recipes, and make it generate more text that somewhat resembles a cookie recipe. Neural networks can't think, but they can find underlying patterns in the data they are fed. In the case of the cookie recipes, a successfully trained neural network is most likely going to generate something that mentions half a cup of sugar, chocolate chips, and preheating the oven to 350 F.

Just, not necessarily in a coherent way. The neural network doesn't know what chocolate chips are, what cups are, what an oven is, what a cookie is, so... you'll be lucky if a neural-network-generated recipe is even possible, let alone edible, and let's forget tasty.

As you may already be guessing from our cookie example, we are fans of the work of Janelle Shane of AiWeirdness. She does fun experiments with letting text-generating neural networks "be weird" and create funny output, one of her favorite things to generate being surreal cookie recipes. Inspired by her work, we wanted to try our hand at playing with a neural network too. We set up for ourselves tensorflow-char-rnn and were ready to go. But what could we train it on?

Chapter 4 Page 18
Drawn magically

We couldn't resist the temptation to see how a neural network would fare with generating more of The Gifts of Darkness. As much as Rosy loves making it, she wishes sometimes that she could sit back and just read it, it having magically appeared from somewhere, rather than needing to decide on every word and every panel and every curve of every eyebrow. The neural network we were working with would use text only, so it wouldn't be able to generate a comic page or anything visual like that, but we could still feed it the textual draft of The Gifts of Darkness and see what it would do. Although, as of this writing, the comic is reaching the end of Chapter 7, the draft is already fully written until Chapter 27, so we were able to feed that to the neural network. We also know that neural networks do well with larger datasets, and this is the biggest chunk of text we have handy, so it should be able to do something with it.

Except, as we said before, neural networks can't think, don't know what any of these words mean, and their results might not be coherent. Rosy can read some of this surreal draft and giggle, but she better keep writing it herself for real.

This is a typical output:

"Oh, yes", Adrien chuckled. "I -- I am so sorry", Val said with a frown in a deep breath. "It's alright", Adrien laughed. He passed to Val's thighs and interested to the expression - he couldn't help but turn towards Val to wash - he had just showed to Adrien as he stood up and placed the door and took a bit looked with a fine nod as he given the little bit on his brow things, his hands with a night light problem as he firaped them for a moment; and sat somewhat had askuded to meet the warmth of breakfast in the light and avalled.

There are words. There is narration, dialogue, dialogue markers, and the characters are there. It's even figured out semicolons. It even does a good job with capturing the cadence and the rhythm of Rosy's writing. However, none of this makes any actual sense. Adrien did what with Val's thighs? What's "firaping" or "askuding"?

One thing to make super clear here is: the neural network can't invent anything. It can only use letter combinations that it has already seen in the pre-existing draft, with a bit of randomness. Sometimes, very rarely, by pure accident, it creates something that is a real word that isn't in the draft, but don't imagine it's being smart - it still is using the pre-existing data to make letter combinations that might be likely, and happened to put together a word that does exist. For example, in one instance it made up "counterpointed", which is nowhere in the draft and indeed a word. Most of the time, however, its attempts to make new words result in nonsense like "askuded".

Paper balls

And because the neural network can't invent anything, it will never be able to use plot elements that haven't happened yet, so all it can do is create a smush of what was already written. It puts the entire draft through the blender and looks for what letters and word combinations are frequent, and tends to use them more. For example, paper balls are really common in Chapter 5 but nowhere else, but still that won't stop the neural network from using them liberally everywhere. The alchemy laboratory is a later feature of the plot (not yet in the published webcomic), but the neural network doesn't know that, and just wants everyone to do alchemy all the time, even while also dealing with paper.

He closed his head fearing that paper made the wall; it had just why, and the hands back in letter; the alchemy instant, in its sink, Adrien took in his face in side of succession, and he was say.
Val and the staff
There's only one word for that thing and it is "staff".

The neural network is looking for common letter combinations, not concepts. So it might have its perception skewed by things that must be conveyed with one specific word, thinking that that word is more common and important than another concept that has multiple synonyms to convey the same thing. For example, there is no other word that can be used for Val's magical staff than simply "staff". That's what it is, that's what it's called, and the top difference you'll get there is the plural of "staves". But on the other hand, the idea of magic can be described as "magic", "spell", "enchantment", simply describing that Val moved his fingers, that Adrien drew a magic circle, and so on. So the neural network will use the word "staff" like it's going out of style, but not favoring any of those magical words, even though they are in fact a more common plot element than the staff itself.

Another word that's everywhere is "table", since a good portion of the comic takes place with Val and Adrien talking over breakfast, lunch, and dinner at the table. So tables have a tendency to appear. Kind of at random.

Adrien laughed in the staff and drompepted him. He adjusted a bit dashing and sat on his head and as he knew on the table around them.

Another interesting thing is the prevalence of "water". Here, the neural network is skewed because frequently through the draft there will be mentions of drinking glasses of water, also the Water element, water in the stream, water in the shower, and on and on. In all these cases, it's called water, so expect to see a lot of water.

"What do it's not doing water", Val said. He tracked his fingers, at it in in a stomach with water.
The Gifts of Darkness is a comic about the importance of proper hydration.

The neural network got a general idea of who the characters are, but is usually not capable of distinguishing the character voices or to alternate the dialogue. It only can remember so many letters that it's put down already, and by the end of when it's made a longer line of dialogue it can't figure out who said it. The neural network is capable of mimicking the character's voices, but, because of its short memory, it cannot attribute them to the proper characters consistently. So we will be reading some generated dialogue and have an idea of who is saying it... and then we'll get to the dialogue marker, and jarringly, the neural network says it was the wrong character speaking. For example, Adrien has certain nervous tics to his speech patterns, and Val does not, but the neural network doesn't know that:

"Wow", Val said with a smile. "Yes, I just -- I'm glad to work it to be the days".

Considering it only knows different letter combinations, the neural network also doesn't and can't understand that Val and Valerion are the same entity. What it does know is that both names occur a lot, often after dialogue lines, so it will use them. At the same time. So we get Val talking to Valerion.

"I am sorry", Valerion said, wide-eyed. "Well", Val smiled, still leaning a little smile.
Call me Val
He'd rather be called Val.

Also, the neural network isn't keeping track of who is in a scene at any given time, so sometimes Anne, the barkeep that Adrien met back in Chapter 1 (and who is mentioned again later in the draft that we used), will appear suddenly in the practice tower and interject.

"Yes", Anne could have that exactly grew to his right with the wall again; and expected. He became a sponge.
I'm Anne, and I'll show up randomly to comment on what's happening!

The neural network also doesn't know how to end scenes or chapters, even though these are things present in the draft. Only once did we see it do a scene change with the *****, and never once have we witnessed a chapter number or anything of the sort. For the most part, it keeps rambling endless dialogue and sometimes some narration. To be fair, chapter changes have only happened 27 times, but dialogue and narration is the rest, so it doesn't realize that something not being very frequent doesn't mean it's not important. Since it's using all of the draft as its dataset regardless of mood or plot developments, sometimes it writes sexual tension that quickly dissolves into chuckling over the table. Or angst that continues in drawing spells.

Anyway, for your reading delight, here we have a collection of our favorite lines that the neural network generated. Rosy even sketched some of them! Enjoy!

Adrien laughed. "That is a triangle - and amazing to wake you, if you must think I won't be many".
"Ike", Val chuckled.
The glasses of hearing. "Anything?", Adrien chuckled.
"Onwomiter", Adrien whispered.
"No, no -- ow -- thank you", Adrien laughed, a side of failed.
Adrien practiced. "It is enchantment", he said.
Val chuckled behind his smile.
Adrien put down and looked up and throwing his dinner and the books, eating a while; it had been effort.
Valerion was a smile.
Valerion chuckled with his eyes; he calmed with a pantly table
"I have to that", Adrien whispered. "I think I've amazing? Ah --".
"It's alright", Val said with a smile.
"You -- yes -- why it is", Adrien said.
Val smiled: Adrien felt like another nice middle.
"You like a pup of magic to him, yes", Val chuckled.
"It's a few saginal teach feeling of hot?".
"I am too feeling as more - except - the more fine".
"Goodnight and water?", Val said.
Goodnight and water
"I supposed to be, I got it. I just circle. If you're still death, if I don't imagine".
Valerion could not be a feeling...
"Yes", Val replied with a little coffee.
Valerion laughed coffee
"Thank you". Adrien focused his fingers in front bread. He an expression as he will have not continued: He chuckled.
"And it was any jam wonderful!".
Adrien had been set from his private finger cutting
"And kind", Val smiled, his black shimmering great fruits against the table that moved the laboratory.
Val felt his hands in it's the index fingers. "I am so lick?".
Adrien chuckled at the shower.
"Watching discuiting?", Adrien added within him. He walked towards ham of the table.
"I have a pillowess of the seat of work". "Really!", Adrien said.
"Right much night dinner, yes. That is power", Val said, spinning.
All these opened the stone spoon with his heart - he was closed in his dark. He walked towards him; the great deep and started each table smile that he wanted his feet against the door to removed away - the bite you're almost as he clapped the table in his slice of his arms expression of which he was best dropped in front of the top of a prince and set from the tip of extress.
Adrien picked up the south and continued.
"Well", Adrien said, and then noticed the sponge towards his head.
"Yes", Val said with a smile. "I don't know you are not me", Adrien said.
He smiled, smiling at him; then he ate in his arm glass eyes from his eyes.
Val sank his eyes.
Adrien knew it. "Yes", he said. "At least with breakfast proeding the silence sabidies in the answers of with faited written, changed on a small plate, and the staff and strange where he sat with a smile. "You know it was overcover Adrien", Val said, so love on his mouth and smiled, it was as if Adrien sat upwards on his head. "Well!", Valerion chuckled. "Whichseld it is a scarf now?".
"Now", Adrien said. "And I see", he heard the table.
"We can do that?".
"In any home".
"Really?", Val smiled.
"Thank you", Adrien replied.
"Thank you", Val said, stretched his laughter.
"Oh, no, no, you like to shake it, and there were in it never disappointed...".
Val problem in his mouth.
"It's alright. So, I am sorry that I was alright, and I -- I don't know?".
"Yes, yes, I don't mean to be a sorcerer anything that alchemy, and the easy day".
He opened his eyes as he opened his face. "Wow", Adrien replied.
Val was cold path, and Adrien did not sure he was just a floor
"I really are just -- that's -- that is just -- of course, I -- I went to carefully be a more".
Then he walked towards his face. He began to be great, and the wands of hearing it glow of a bit in the room he had never seen sure he spoke against his best, then he set a book again, and the silence was particular
On the middle of the second wish, his spells you have not seen the fork that was a word of excepted again to retreat to the stone windows and turned around and took a little time in bread and tried to slightly more than Val was try, he drew the table on his eyes. "How looks at all".

"You are become really just -- what about the ball. I don't speak that I don't think I think I'm sorry".

Adrien lifted the bed on his arms.
Val started doing and then he draw a little tower in his grin.
"I -- I'm not -- a wonderful", Adrien finally said
I'm not a wonderful
"I have been hurty".
"I must know, I think -- I -- I don't know, take here".
"I don't don't have to have to have to think", he chuckled.
"Right, that is a silence of picking behind the wall. That is not magic".
"Well, my great tower", Val said with a smile out of his hands.
"I don't have myself. I think I'm case, yes", Val smiled; "I was gark?".
Adrien had decided to sit the fireplace. Adrien proceeded a close bread and set a little towel on his face. Starting around the staff from his fingers. "It was so talk for you. You want to be great to strange their better recipe will be a bits".
Val added as he watched his cheeks, and leaned back with his magic and cleaned the stone rained, his wise in the place to his arms, his fingers furrowed again.
his eyelids closed his eyes
"That's a wall in the middle of the woods", Val said.
Adrien reached his mouth. "How does not get my intense in the large".
"I don't think I'm have all me...".
"We would be so much", Adrien said as he pounded up from his face; his head slightly laughed. "I was expecting you...".
"What do you contain the whole silence, too".
"Yes, yes, yes", Val chuckled
He sat down, and they was sitting on his gaze.
"Wow", Adrien said. "Wow", Adrien said. "Oh, I am so much".
"I see", Adrien said with a smile. "That would be the table you can take to hold it!".
"No, it was the window -- you're not left".
He spoke. "I was completely water?".
Adrien stretched Val to his face. "It is a second".
Oh, no -- that's true, helled!
"It's the spell of panting".
"It's alright", he said, his head flowered. "But --".
Valerion smiled, and he ate his hand.

For more neural network nonsense, see the continuation of this post, made for the following April's Fools.