Original PDF
Chapter 03

Realtime sequence generation with continuous control

3.1 Introduction

In the previous chapters, we presented a number of examples and applications of Deep Neural Networks being used for creative media generation across a wide range of media. While these examples have often demonstrated very impressive results, the topic of Meaningful Human ControlFootnote 1, and in particular Realtime Continuous ControlFootnote 2, remains an open issue.

One of the challenges that we wish to overcome, is that in many of these existing systems the entire output is often generated in a single timestep. For example, when working with a generative image modelFootnote 3 such as ProGAN, we can sample a random 𝒛~𝒩(0,1), and an entire 1024x1024 pixel image is generated in one go. We do have the ability to modify this image via latent manipulationsFootnote 4, however we envisage a system which allows more control while the image is being generated. In other words, we imagine an image being sketched out by a software in realtime — as if we are watching a person draw the image — and we can somehow guide the software while it is sketching. Another example concerns generative text models such as Char-RNNFootnote 5. These have become very popular, as they can produce believable, though often hilariously erroneous, pieces of text. However, at the time of our research, there are no tools available that allows a human to have any kind of meaningful control over the text generated, let alone in a Realtime Continuous manner.

In other words, we are interested in developing generative systems which continually and incrementally produce some kind of an output — for example drawing a sketch, or typing out text. And at any time, a person can meaningfully interact with and guide the system with Realtime Continuous Control. As we described in section 1.4: Visual instruments: Realtime Continuous Control, we use musical instruments as a metaphor to think of these systems as visual instruments. These are not used by a user, but are played by a performer.

In this chapter, we present two studies that investigate this topic, and we specifically focus on the two examples that we mention above: drawing sketches, and generating text.

3.2 Collaborative generative sketching with MCTS and CNNs

3.2.1 Introduction

In this section, we present a method for collaborative, generative sketching using Monte Carlo Tree Search (MCTS) and discriminative Convolutional Neural Networks (CNN).

Even though this experiment was not able to produce the realistic results that we were hoping for, based on our findings and the questions that our research set out to address, our paper (Akten & Grierson, 2016a) was accepted to the Constructive Machine Learning Workshop at the Thirtieth Conference on Neural Information Processing Systems (NeurIPS) in 2016. Furthermore, the system that we described and were hoping to build, was later replicated — though with a very different technical approach — in Google's Sketch-RNN(Ha & Eck, 2017)Footnote 6 and the associated online collaborative drawing applicationsFootnote 7.

3.2.2 Background

As we mention above, in a typical Deep Learning based creative workflow, the entire output is generated in a single timestep. This is especially true of images. One of the main reasons for this, is that images are represented as bitmaps, a dense grid of (Red,Green,Blue) tuples. Generative models such as VAEsFootnote 8 or GANsFootnote 9 model this representation, so that when we take a sample from the latent distribution of such a model, this produces an entire image in a single timestep.

There are a few notable exceptions to this. Auto-regressive models such as PixelRNN (van den Oord, Kalchbrenner, & Kavukcuoglu, 2016) and PixelCNN (van den Oord, Kalchbrenner, Vinyals, et al., 2016) also operate on bitmap images. However, in these models, each pixel value is conditioned on all of the previously generated pixel values. Generating an image with PixelCNN or PixelRNN does not happen in a single timestep. Instead it happens pixel by pixel. Technically this could allow for Realtime Continuous Control, if a suitable interface were designed. However, generating an image pixel by pixel in this way is not only incredibly slow, we do not believe that a bitmap representation is optimal for Meaningful Human Control in this context. The manipulations that we seek to make possible, are not on a pixel level, but are at a higher, semantic level.

Another exception is Google's Sketch-RNN. Sketch-RNN was released a year after we presented our research first at an internal workshop at Google's offices in San Francisco, and later at the Constructive Machine Learning Workshop at NeurIPS 2016. The researchers use a very different technical implementation to what we describe below, however their motivations and the functionality of the system and web applications that they develop is the same as what we propose below and in our original paper. This is to say that they develop a system that is able to draw arbitrary sketches of various different categories. Furthermore, a user can initiate the sketch, and then the system can recognise what the user has drawn — for example, the tail of a cat — and then complete the rest of the drawing accordingly. In Sketch-RNN, the authors train a generative sequence model on vector representations of strokes. One of the biggest challenges of such an approach, is having a large enough dataset of vector drawings to train on. At the time of our research, there were no such publicly available labelled datasets. For Sketch-RNN however, the researchers were able to use an internal dataset of over 50 million vector drawings, which was made publicly available later that year (Quick, Draw! Dataset, 2017).

3.2.3 Overview

In this study, we aim to develop an agent that can wander around the screen, trying to sketch out drawings that resemble specific objects as chosen by a person. The agent doesn't create a drawing that mimics a specific target picture. That is a relatively well established area of research and artistic inquiry (Tresset & Deussen, 2014; Smith & Leymarie, 2017). Instead, in this study, our aim is to allow the agent to take any actions it chooses, and follow any path that resembles a desired image class. For example, if the agent is asked to draw a cat, the agent will sketch any cat that it imagines, not a specific cat presented to it in any picture.

Most crucially, the agent should not decide the entirety of what the final image would be in an instant. I.e. it should not sample a random cat image from a latent space (as one might do with a GAN or VAE), and then sketch what it has sampled. The final image should not be decided the instant the agent starts drawing. The agent should know what a cat looks like, it should plan ahead and start drawing, but continuously adapt its actions as it responds to its own drawings. This would allow for a person to interact with the agent while it is drawing. A user could push the agent around (e.g. by exerting forces on it) and directly affect the drawing. In addition, the user could directly draw on the canvas too. Seeing this, the agent should adapt. E.g. while the agent is drawing, if the human draws a partial sketch that resembles a tail, the agent might recognize that, and draw the rest of the cat to fit to the tail drawn by the human. The agent should continuously monitor the page, and intelligently incorporate the current state of the drawing into its future plans. It should see, imagine, plan and respond. This should be a collaborative process, that evolves in realtime, continuously and interactively.

There has been prior work in generating bitmap images based on image classes, and prior work in generating drawings that mimic specific target bitmap images. However, to our knowledge there has not been any prior work in directly generating vector drawings based on image classes, let alone in a way that is able to adapt and collaborate based on input from a person. Google's Sketch-RNN, which was released the year after this study, also does exactly this.

As a guiding framework, our system is designed around these basic principles:

  • Creativity: as an efficient method of searching a large space of actions or decisions,

  • Imagination: as the ability to simulate many different scenarios and outcomes,

  • Evaluation: as the ability to evaluate both the current situation, as well as the outcome of many imagined actions and scenarios, against some desired criterion,

  • Collaboration: as the ability to respond — somewhat intelligently and creatively — in realtime, to some kind of external input, such as the actions of another user.

3.2.4 System description

Our agent acts similar to a LOGO Turtle (Papert et al., 1980). It can move forward, and rotate left or right by a number of degrees. It can move leaving a trail (analogous to pendown in Turtle) or without leaving a trail (analogous to penup in Turtle).

At the heart of the decision making process driving the agent, is Monte Carlo Tree Search (MCTS) (Browne et al., 2012). MCTS is a very efficient, probabilistic approach to exploring a vast decision space while aiming to maximise future cumulative rewards(Browne et al., 2012). We present a more detailed explanation of MCTS in the previous chapter subsection 2.3.20: Monte Carlo Tree Search.

Our system runs at approximately 2-5 frames per second on a medium level laptop, depending on various parameters such as rollout depth. At every timestep, the following actions are performed (for a diagrammatic overview, please see Fig. 3.1):

  1. MCTS performs many simulations, known as rollouts, where the agent takes random actions. These rollouts are performed for an arbitrary number of timesteps into the future. We consider this to be the agent imagining what would happen if it took particular actions.

  2. At the end of each rollout, the simulated trajectory or drawing, is rendered into a texture and fed into an image classifier, such as a CNN trained for image classification. This is to evaluate how much the simulated, imagined drawing resembles the desired image class.

  3. The desired class probability returned from the classifier is backpropagated through the partially expanded decision tree as a reward towards choosing the optimal action for that timestep.

  4. Hundreds or even thousands of simulations are performed, trajectories imagined and evaluated per timestep. Because of the probabilistic nature of MCTS, and the balance between exploration vs exploitation, the system converges towards imagining actions and trajectories which are more likely to produce desired outcomes — i.e. drawings with higher resemblance to the desired image class.

  5. When a predetermined time budget is reached (e.g. 100ms), MCTS stops simulating new actions and trajectories, and picks the most robust child, i.e. the most visited and thus promising action. (Using a predetermined time budget allows the system to remain realtime at interactive rates. Smaller time budgets allow higher framerates at the cost of less optimal actions, while higher time budgets drop the framerate but allow potentially more optimal actions).

  6. The agent then performs the selected action to make that move.

  7. At the next timestep, this process of imagining and evaluating is repeated.

In summary, at every timestep, hundreds of simulations are performed imagining hundreds of alternative actions and paths. Our system is able to efficiently search this very large space of actions via MCTS's optimal branch selection; it is able to imagine the outcome of many different scenarios via the MCTS rollouts; it is able to evaluate situations — both current and imagined, also incorporating inputs from a user — via the classifier; and it is able to integrate all of these into its response and future plans, resulting in a collaboration.

How the sketching system combines Monte Carlo tree search with a convolutional classifier.
Figure 3.1 Overview of how MCTS and the CNN is integrated

Interestingly, parallel to our work, a similar architecture using MCTS to select actions where a CNN is used to evaluate imagined rollouts was also later used by Google Deepmind in their seminal AlphaGo, which beat human Go champions Lee Sedol and Fan Hui (Silver et al., 2016).

The agent can move forward with nspeeds number of different speeds to choose from, ranging from smin to smax. It can also rotate with nrotations number of different rotations to choose from, ranging from −rmax to +rmax. In other words, the agent can turn anywhere from −rmax to +rmax, in (2*rmax)(nrotations−1) degree increments. Thus the agent has na=nspeeds*nrotations total number of actions to choose from. We have tested a wide range of configurations of parameters, and an example configuration is as follows:

nspeeds:=2,smin:=0,smax:=2,rmax:=30,nrotations:=7⟹na=14

For more details please refer to the paper (Akten & Grierson, 2016a)

Classifiers

We performed tests with three different classifiers:

Multinomial Logistic Regression (MLR) trained on MNIST

The first model we use is a simple Multinomial Logistic Regression (MLR) that we train on the MNIST dataset of hand-written digits (LeCun & Cortes, 2010). This model is simply a softmax activation (Bishop, 2006) on a linear transformation of the inputs, and can be formulated as

𝒚
=softmax(𝑾𝒙+𝒃)
(3.1)
softmax(x)i
=exi∑jexj
(3.2)

where 𝒙 is the input vector containing the flattened input image pixels, 𝑾 and 𝒃 are respectively the weights matrix and bias vector to be learnt, and softmax is a function that converts a vector of log probabilities to a normalized probability distribution.

We train this model using stochastic gradient descent and backpropagationFootnote 10 trying to minimise the cross-entropy (Bishop, 2006) between y the predicted probability distribution of our model, and y′ the true distribution, i.e. the training data.

H(y′,y)=−∑iyi′log(yi)
(3.3)

Unsurprisingly, this model does not generalise very well, scoring approximately 90% on the validation dataset. Since the model is simply a softmax operating directly on a linear transformation of the raw pixel data, it is very restrictive on the types of inputs that it can classify, and does not provide much translational, rotational or scale invariance. In other words, as a classifier, it is far from optimal. This is important to note, as we discover that less optimal classifiers, perform better in a generative context. We will discuss this in more detail shortly.

LeNet (Convolutional Neural Network) trained on MNIST

The second model we use, is a Convolutional Neural Network (CNN)Footnote 11 very similar to the classic LeNet5 (LeCun et al., 1989), that we also train on the MNIST dataset. We use two convolutional stacks, each stack consisting of 5x5 convolution kernels, followed by a rectified linear unit (ReLU), followed by a max-pool layer. After the two convolution stacks we use a dense fully connected layer with a softmax to convert the log probabilities into a probability distribution. We then train with stochastic gradient descent and backpropagation to minimise the cross-entropy.

To prevent over-fitting, we use dropout regularization (Srivastava et al., 2014). During training, neurons are randomly omitted with a fixed probability to prevent them from being too specialized. During inference (feed-forward), all neurons are enabled. In effect this is likened to training an ensemble, where many different networks with different architectures are trained simultaneously and averaged for prediction. We use a dropout probability of 50%.

This model scores 99.2% accuracy on the validation data and proves to be much more resilient to noise compared to the MLR. It demonstrates very good translation and scale invariance, with acceptable rotational invariance.

Inception-v3 (Convolutional Neural Network) trained on ImageNet

For the third experiment, we download and use a pre-trained model: Google's image classification architecture Inception-v3 (Szegedy, Vanhoucke, et al., 2015) trained on ImageNet (J. Deng et al., 2009), a dataset consisting of millions of labelled images classified into one thousand classes. This model reached as low as 3.58% error in the 2012 ImageNet validation set for Top-5 error and was state-of-the-art at the time.

A screenshot from our software, running the MLR model trained on MNIST.
Figure 3.2 A screenshot from our software, running the MLR model trained on MNIST. The top left panel shows the current state of the canvas for the current timestep, the top middle panel shows the scaled down drawing used for evaluation, and the top right panel shows a visualization of all of the current MCTS rollouts for the current timestep. At the bottom of the screenshot, the class probability distribution shows that the classifier returns 100% confidence that the current state of the drawing is the digit ‘3'.

3.2.5 Results and discussion

As a result of these experiments, we observed that our system seemed to perform well, but did not always produce the results that we would expect or hope for. This unearthed some very interesting artefacts with regards to how CNNs learn to classify images. Our key finding with regards to these unexpected results, is that discriminative CNNs that are trained for image classification, are not well suited to generative applications in this manner, as they provide too many false positives. This in fact mirrors the findings of Nguyen et al. (2015), which was published while we were conducting our own research. The researchers use a very different method to ours. They use evolutionary algorithms to optimise for images that maximize class probabilities. For this reason, the aesthetic qualities of the images that their system produces is very different to ours. However, the conclusions are the same: there exists a space of images which are very ‘unnatural', and would be classified as ‘random' by humans, but are classified by CNNs with very high confidence, as belonging to specific classes.

Fig. 3.2 shows a screenshot of our software, running the MLR model trained on MNIST. In this particular case, we set the desired class to ‘3'. As can be seen in the panel in the top left, the current state of the agent's drawing clearly resembles the digit '3'. The top right panel shows all of the MCTS rollouts for the current timestep, i.e. these are the simulated, imagined paths. Every single one of the rollouts are individually evaluated by classifier, and the class probability is used as a reward for the action that led to that path. Along the bottom of the screenshot, red and blue bars visualize the distribution of class probabilities, i.e. the classifier's confidence that the current state of the drawing belongs to each of the classes. In the video it can be observed how these rise and fall as the agent draws on the canvas and the drawing evolves. However, in Fig. 3.2, there is only one single red bar visible, because the classifier returns 100% confidence that the drawing resembles the digit ‘3'.

Of important note, is that the classifier here is not a deep Neural Network. It is a softmax regression on a linear transform. So as mentioned previously, as a classifier, this model does not perform optimally. However, as we use it in this generative context, it is able to guide the agent to create images resembling the desired class.

Using a more complex, deep architecture however, gives very different results. Fig. 3.3 shows a screenshot of our software, running the Inception-v3 model trained on ImageNet. In this particular case, we set the desired class to ‘meerkat'. Most people would probably think that the image in the top left panel is some kind of noise, and is quite far from resembling a meerkat. So it seems our system has failed in this case. However, interestingly, looking at the class probability distribution along the bottom of the image, it can be seen that the classifier is very confident — in fact with 100% probability! — that the image drawn by the agent is indeed a meerkat.

Similarly, looking at Fig. 3.4, we can see the results of running our system using the same classifier, where we set the target class to ‘white wolf'. Most people would again probably think that the image is a different kind of noise, and does not resemble a wolf at all. However, the classifier is still very confident — with 98% probability in this case — that the image is in fact a white wolf.

The failure in both of these cases, and all of the experiments that we ran using Inception-v3, is not a failure of the planning performed by MCTS, or of the way that MCTS is integrated with the classifier, or the backpropagation of the classifier confidence as a reward signal. In fact, the MLR study is a good demonstration that the overall system architecture and concept works. The failure in the latter cases, is because Google’s very deep model trained on ImageNet, is incorrectly classifying these random-looking textures as the desired class, with almost 100% confidence. In other words, the classifier is feeding an incorrect positive reward signal into MCTS. This is causing the agent to wander around the canvas in a manner that appears to humans to be random noise, but is classified by the network with close to 100% confidence to be the desired class.

After many tests like this, it became clear that as image classification models become more complex and accurate at classifying images, they became worse for use in a generative system as this one. Discriminative models with deep, complex architectures such as Inception-v3 are trained to classify images with high levels of translation, scale, rotation and noise invariance. Thus they generalize very well, and can classify natural images correctly with very high accuracy and confidence. However, as an undesired side effect, they also learn features which encourage them to incorrectly classify unnatural images — such as very particular distributions of noise and abstract shapes — with equally high confidence. In other words, the manifolds of the classes successfully capture the space of associated natural images, but they also include undesired, unnatural images as well. They produce a lot of false positives.

A screenshot of our software, running the Inception-v3 model trained on ImageNet with desired target class set to ‘meerkat'.
Figure 3.3 A screenshot of our software, running the Inception-v3 model trained on ImageNet with desired target class set to ‘meerkat'. At the bottom of the screenshot, the class probability distribution shows that the classifier is 100% confident that the drawing is of a 'meerkat'.
The same configuration as Fig.
Figure 3.4 The same configuration as Fig. 3.3 except the desired target class is ‘white wolf', and the class probability distribution shows that the classifier is 98% confident that the drawing is of a 'white wolf'.

As a result of this, our generative system was not able to produce the kinds of images that we were hoping it could produce. For this reason, we did not invest more time into designing and developing modes of interaction which provide Meaningful Human Control, or Realtime Continuous Control. Instead, we chose to rethink our approach, and focus on an alternative study, which we discuss in the next section.

3.3 Realtime interactive text generation with RNN ensembles

3.3.1 Introduction

In the previous section, we presented a method for collaborative generative sketching, whereby we combine MCTS with a Deep Neural Network classifier. Our goal, was to create a generative system which continually produces some outputs (in this case, drawing sketches), and at any time, a person can meaningfully interact with and guide the system with Realtime Continuous Control. While our system worked overall as intended, it was let down by the fact that a discriminative Deep Neural Network returns too many false positives for it to provide reliable feedback.

With this in mind, in this section we investigate the use of a generative sequence model, in a similar Realtime Continuous interactive setting. Instead of continuing to work with images, we choose to perform this study with generative text. This is due to a number of reasons. First, in order to build a generative sequence model of images, we would need a suitable labelled vector-based dataset, and this was not available at the time of our research. Google's Quickdraw dataset would not be available for more than a year (Quick, Draw! Dataset, 2017). Second, as we discussed in subsection 2.2.7: Char-RNN, character-based generative text models were becoming very popular. However, the tools available at the time did not provide any form of Meaningful Human Control over the text generated, let alone in a Realtime Continuous manner.

For this reason, we adapt our question to the domain of interactive character-based text generation. Our aim is again to create a generative system that continually produces some outputs, in this case not drawing but producing text character-by-character, while allowing a user to meaningfully interact with the system and guide it with Realtime Continuous Control. We again take the idea of visual instruments, as we described in section 1.4: Visual instruments: Realtime Continuous Control, as very strong design guidelines. And we try to design the system such that users are more like performers that play the system.

Our paper on this study was accepted to the Recurrent Neural Networks Symposium at the 30th Annual Conference on Neural Information Processing Systems (NeurIPS 2016) as a poster presentation (Akten & Grierson, 2016b), and our prototype was accepted to be a live demonstration on the general NeurIPS conference demo track.

3.3.2 Background

For this study, we use an ensemble of Long Short-Term Memory (LSTM) (Hochreiter & Schmidhuber, 1997) RNNs. More information on these architectures can be found in subsection 2.3.19: Recurrent Neural Networks (RNN). In particular, our implementation is based on the character-based text model as described in Graves (2013), which is also the foundation for Karpathy's popular Char-RNN.

RNNs are a type of neural architecture with cyclic connections. These allow the network to learn temporal patterns, which in turn allows RNNs to be very effective for sequence modelling. Notably, Graves demonstrates the use of LSTM RNNs to generate many different types of sequences, one of which is generating text character-by-character (Graves, 2013).

An LSTM RNN has an internal state which can be represented as a tuple of (𝒉t,𝒄t) where 𝒉t and 𝒄t are the hidden state and memory cell vectors respectively at timestep t. At every timestep, these values are fed back into the network, and this effectively allows the network to ‘remember' events from the past, and use that information to affect the predictions it makes for the next timestep. In order words, the predictions made by an RNN, is conditioned on the input, and the RNN's internal state at that point in time.

In the case of character-by-character text generation, this equates to an RNN which outputs a probability distribution over all characters, given previous characters. To generate text, we sample this distribution to generate a character, and then feed this character back into the RNN to update its internal state. Repeating this procedure, we can generate long pieces of text.

However, the typical workflow at the time of our research, follows the same patterns that we describe in section 1.3: Meaningful Human Control under the subsection Pressing a button. This can be summarised as: i) collect some amount of data, ii) train a model on the data, and iii) press a button or run a script to produce a large chunk of text in the style of the training data.

With this workflow, there are two ways in which a person can influence the output of a Char-RNN model. The first is through the curation of training data. A Char-RNN model trained on the works of Shakespeare will generate text similar to Shakespeare, while a model trained on C code will generate text similar to C code. But once a model is trained, a Shakespeare model will not be able to generate text similar to C code or vice versa.

Regarding generative RNNs, there is another method of influencing the output, which is more subtle. This is known as priming. When a forward pass is run on a trained, but unprimed Char-RNN, its internal state will be uninitialized to begin with, so the distribution output will be unknown, and most likely random. Sampling a character from this distribution will be also be random, from an unknown distribution. To prime a model, we simple run forward passes on the trained model with each character of a seed text. Each forward pass with the next character from the seed, updates the internal state of the model. Once the entire seed has been fed into the model in this way, the model has been primed to continue from the seed. In other words, when the next forward pass is run, the distribution output will be biased towards continuing from the seed text. For example, if the Char-RNN is first fed the individual characters from ‘Good Mo', this will set the internal state such that, when a forward pass is next run, it will output a distribution where the letter ‘r' will have a high probability.

This is an effective way to influence the output of generative RNNs, and grant some level of control to a user. Using these methods, artists such as Ross GoodwinFootnote 12 and Allison ParishFootnote 13 have created a number of influential text-based artworks.

However, the tools available still do not allow the level of control that we seek, especially with regards to Realtime Continuous Control, and thinking about visual instruments.

The question that we set out to investigate with this particular study is: Is it possible to control the output of text, and change its style in realtime, whilst the text is being generated.

3.3.3 Overview

We will first describe the functionality that our solution provides, as we believe this to be more important of a contribution, compared to how we actually implemented it. We will briefly summarise our implementation in the next section.

Our interactive Char-RNN ensemble software is designed to run across two displays presented side by side. This original layout can be seen in Fig. 3.5. To aid reading in print, Fig. 3.6 shows the two screens stacked vertically. On the left we have the interaction screen. This is displayed on a touchscreen monitor to aid seamless interaction. On the right we have the output screen. This is where the text is displayed as it is being generated, character-by-character.

Screenshot from our dual-screen interactive Char-RNN ensemble software.
Figure 3.5 Screenshot from our dual-screen interactive Char-RNN ensemble software. On the left is the interaction screen which we typically display on a touchscreen monitor. On the right is the output screen where the text is displayed as it is generated character-by-character.

Styles

The user is presented with two dozen icons representing text styles. These can be seen in the top leftmost panel in Fig. 3.6 under Style activation, and they include a wide range of texts including the works of Shakespeare, Jane Austen, Mary Shelly, Friedrich Nietzsche, Charles Baudelaire, Carl Jung, texts from the Dalai Lama, the Iliad, love song lyrics, the King James Bible, the Chilcot Report of the Iraq Inquiry, cooking recipes, C source code for the Linux kernel, LaTeX code, and many more. By clicking on these icons with a mouse or finger, the associated style is activated or deactivated. When a style is active, its icon appears in the Style weights sliders and Style weights gestural interaction panels.

Internally, all styles are always loaded into memory. This allows for the realtime activation or deactivation of styles with no time delay or overheads, or any negative impact on the momentary performance of the software. Potentially, loading too many styles could have an impact on memory requirements. However, with two dozen styles loaded, we saw no issue on a medium-level laptop at the time of this research in 2015. Temporarily activating or deactivating a style from this panel, simply adds it to (or removes it from) the interaction panels. This allows the user to reduce clutter on screen and simplify the interaction by temporarily deactivating undesired styles.

When at least one style is active, the system starts automatically generating text. This can be seen in the output panel in Fig. 3.6. This text appears character-by-character, at approximately 10-20 characters per second. It is reminiscent — and symbolic — of a person typing on a typewriter.

The two screens from Fig.
Figure 3.6 The two screens from Fig. 3.5 stacked vertically for ease of reading in print.

Style weights sliders

While the system is generating text in this manner, the user is able to adjust weights for each style via the onscreen Style weights sliders. These can be seen in top centre panel of Fig. 3.6. For example, while the system is generating text in the style of the Bible, the user can start mixing in a little bit of Mary Shelley, and then mix in a little bit of the poetry of Coleridge etc. This does not affect the text that has been generated so far. It only affects the new text that is being generated at that moment. In this way, styles can be changed mid-sentence, even mid-word.

Styles can be swapped fully. Bringing a new style in at 100%, will bring all of the other styles down to 0%. Again, this can be performed at any time. So a sentence that starts in the style of Shakespeare, can end in the style of Baudelaire.

Styles are not mutually exclusive, they can also be mixed. For example, a memorable outcome occurred when both the love song lyrics and Linux C source code styles were mixed together equally at 50%. Amongst the text that the system generated, was the phrase “static unsigned love”, a mix between “static unsigned long” — a common C expression — and of course, the word “love”.

The sliders allow very precise control over the weights of the styles. For example, it would be possible to set one particular style to 23%, and a second style to 77%. However, we have observed that this level of precision does not have a noticeable effect on the outcome. In our own testing, we observed that relatively large, roughly 25% increments in weights produced noticeable changes in the text generated. When the weights were modified in smaller increments, we couldn't notice any difference in the output. We qualitatively think of using such large increments as off, a little bit on, halfway on, mostly on, and fully on. For this reason, since incredibly fine precision is generally not necessary, we also implement gestural interaction, which compromises precision for expressivity.

Style weights gestural interaction

The gestural interaction panel allows more performative control over the weights of the styles. Here, the active style icons are arranged in a circle as can be seen in the top right panel in Fig. 3.6. Moving around in this space using the mouse cursor or a finger touching the screen, the user can more expressively perform the manipulation of style weights. The weights are calculated based on the distance from the cursor, to each of the icons. This of course does not allow as fine control as using the sliders directly, but we believe that this is a negligible price to pay given the expressive freedom it adds. Especially when we consider that, as we mentioned in the previous section, high precision is not really necessary, and only large changes in weights are noticeable.

Furthermore, using the sliders requires the user to concentrate more on the interaction screen, and in particular on the weights sliders area. This is to ensure that their finger or mouse cursor is on the correct slider. However, the gestural interaction interface allows the user more freedom to look elsewhere, for example they can stay focused on the output screen. This is because with the gestural interface, they only need to be aware of roughly where their finger is on screen. This enables the user to more freely and expressively perform the broad strokes of which styles to bring in, when, and at what approximate levels; without having to pay such close attention to the interaction screen. This makes the gestural interaction model more suitable for performance and expressive interaction, as we describe in section 1.4: Visual instruments: Realtime Continuous Control. In this case, we can think of the user, as more of a performer.

LeapMotion interaction

Going one step beyond the gestural interaction panel, we also developed a LeapMotion interface. LeapMotion (LeapMotion, n.d.) is a small, infrared sensor which is able to track hand and finger pose information in 3D space. Our interactive Char-RNN software also includes LeapMotion control, whereby instead of using a mouse cursor, or a finger on a touchscreen display, the user can simply move their hand in 3D space. We track the tip of their index finger, and its position in space is mapped to the screen to control the weights in a similar fashion to the gestural interaction panel. Just as it was in the gestural interaction panel, very precise position of the hand in space is not very important. Rather, it is the approximate position in space, and when the hand was moved to that position, which is most relevant. Reflecting on the analogy of performing with musical instruments as we describe in section 1.4: Visual instruments: Realtime Continuous Control, this mode of interaction further reinforces the notion that this is not a user using our system, but more like a performer playing with our system to perform the generation of text. In this particular case, it could even be described as a conductor conducting the generation of text.

We developed this interaction model in response to conversations with the performer and experimental poet Jennifer WalsheFootnote 14. We imagined a live performance whereby text being generated by the system is read out loud via a text-to-speech system. In this case, we can remove the requirement for a screen altogether. This frees the performer to move and act much more freely. With a mode of interaction such as the LeapMotion interface, the performer does not have very precise control over the weights. However, given that the noticeable effectiveness of the weights can be thought of approximately and qualitatively as none, little, half, a lot, and full; this level of control can be learnt relatively quickly through building an intuition of how specific points in space correspond to specific styles. For example, “hand near right shoulder” might be one style on full; while “hand near left shoulder” might be another style on full; and in-between the two shoulders, styles are mixed accordingly.

Hearing the output of the system spoken by a text-to-speech interface, the performer can expressively respond with their body to control, steer and conduct the output of the system in realtime, without the burden of having to sit in front of a computer and look at a screen.

We discuss the significance of the LeapMotion interface, along with more ideas in section 3.4: Conclusion.

3.3.4 System description

We implement our software by training a number of different character based LSTM models on different datasets. Given a seed text, each model outputs a probability distribution over all characters, from which the next character is sampled. We run each model on a common input, and we mix the probability distributions that they output. This can be thought of as an ensemble of generative RNNs, collectively outputting a conditional probability matrix at every timestep. Using the style mixture weights as style probabilities, we calculate a joint probability distribution, from which we sample the next character. We provide more details in our paper (Akten & Grierson, 2016b).

Our software consists of two main components: i) a python-based console backend Server which is responsible for loading and running all of the models, and ii) a C++ frontend interactive Visualiser. The two run as separate processes, and communicate via UDP using the OSC protocol. A summary of this architecture can be seen in Fig. 3.7.

Software architecture for our interactive Char-RNN.
Figure 3.7 Software architecture for our interactive Char-RNN. The Server is a python-based console application with no Graphical User Interface, that manages all of the models. At every timestep, the Server receives a seed text from the Visualiser, runs it through all of the models, and returns all of the probability distributions output from each model to the Visualiser. The Visualiser is an OpenGL application which provides the visual interface and interaction. The screenshots in Fig. 3.5 and Fig. 3.6 are from the Visualiser. The Visualiser continually tracks the performer's actions, either via mouse input, tracking the performer's hands using a LeapMotion device, or via faders on an external midi controller. At every timestep, the Visualiser uses these inputs to calculate and update style mixture weights, which are used to calculate the joint probability distribution for the next character. The Visualiser samples the next character from this distribution, updates the screen with this new character, and also sends it back to the Server via OSC, so that the Server can update the internal state of each of the models.

We separate the two processes in this manner as it provides a number of benefits.

It is essential to separate the DNN related tasks, and the graphics and interaction related tasks into separate threads. For an interactive performative system such as ours, it is very important to maintain a stable, high framerate, so that both the animations, and the interaction always feels stable and fluid. For this reason, we ensure that our Visualiser always runs at a fixed 60fps. Feeding data into models and running inference can be a slow process, taking a variable amount of time depending on the number of models that are active. We do not want our visual and interactive experience to suffer, slow down, or feel sluggish when the models are being run. For this reason, it is essential to separate them into separate threads. Separating them into separate processes, effectively gives us separate threads by default, while providing other advantages.

Using separate processes, we can leverage the strength of different software development environments and frameworks. For example, we use python and Tensorflow (Abadi & Others, 2015) for the backend Server managing the DNN related tasks, and we use the C++ creative programming toolkit openFrameworks (Lieberman et al., 2016) for the interactive frontend, as it provides a lot of functionality related to graphics, interfaces and interaction. This greatly speeds up and aids development.

Finally, separating the processes in this way, allows for more flexibility in the deployment of such a system. We have generally run both processes on the same computer, one with a GPU powerful enough to run all required models simultaneously. However, we can imagine a situation whereby we have a lightweight client computer running the Visualiser, and a separate, much more powerful GPU Server running the backend. This GPU Server could even be in the cloud, while the client can be any computer with an internet connection. Migrating to a setup such as this, involves little more than providing the IP address of the Server, to the client computer running the Visualiser.

3.3.5 Results and discussion

When we were previously discussing the concept of mixing styles, we mentioned an interesting outcome that we had observed. When we mixed the love song lyrics and Linux C source code models equally, at one point our system produced the text “static unsigned love”, a mix between “static unsigned long” and the word “love”. In our paper (Akten & Grierson, 2016b), we discuss more of these kinds of examples, and other notable outcomes that we observed. Since these are specific to the case of character based sequence models, we will not detail them in this thesis. Instead, in the conclusion of this chapter, we will reflect on our findings of this study in the context of Realtime Continuous Meaningful Human Control.

3.4 Conclusion

In this chapter, we presented two studies, both of which were investigating the same high level goal: generative systems which continually and incrementally produce some kind of output, while allowing a person to meaningfully interact with and guide the system with Realtime Continuous Control.

Our first study investigated this in the context of drawing or sketching. We implemented an agent-based method, using MCTS to guide the agent, and a discriminative CNN to evaluate the agent's drawings and provide a reward signal. However, due to the amount of false positives that discriminative CNNs produce, this system was not able to produce the results that we were hoping for.

Instead of working with discriminative models, we switched to generative models, and we adapted our question to the domain of text. We developed a software based on an ensemble of LSTM RNNs, that allows Realtime Continuous interaction with this system, to influence the style of the text being generated. This interaction is possible via a number of modes, ranging from very precise manipulation of sliders, to more expressive and performative gestural interaction tracking the hand of the user in space with a LeapMotion sensor. In this latter case, we think of the user more as a performer playing the system like an instrument, or even a conductor conducting the generation of text.

We describe why we believe in the importance of this kind of an approach in section 1.4: Visual instruments: Realtime Continuous Control. While this is an active area of research within the broader field of ML and performance, particularly within music as we mention in subsection 2.2.9: Machine Learning for Artistic, Expressive Human Computer Interaction (AE-HCI), we are not aware of such studies at the time using state-of-the-art DL algorithms.

We do not claim that we have developed the most effective solution or interface for such a problem. Neither do we claim that our system provides optimal usability. Our aim with this research is two-fold.

First, we are investigating how we can introduce points of interaction into DL systems that currently do not allow any form of meaningful or Realtime Continuous Control.

Second, and more crucially, we are hoping to encourage more conversations and thinking in this direction. We were very happy to be accepted to show a live demonstration of our interactive Char-RNN software at NeurIPS 2016, to thousands of researchers. Having spoken to countless researchers at this conference trying our software, we can summarise the responses as ranging from “This is so awesome”, to “I don't understand what this is for. What is the application for this?”. Clearly not everybody shares our priorities. However, many people do. And we would like to help shift thinking in that direction.

Google's highly successful Sketch-RNN and related web applications perfectly address the questions and motivations which we raise in our first study (though with a very different, and more successful technical approach). The popularity and success of very recent research, also looking into Meaningful Human Control over generative Deep Neural Networks (Park et al., 2019; Karras et al., 2019; Simon, 2019; Bau et al., 2019; Karras et al., 2020; Härkönen et al., 2020; Jiang et al., 2020; Broad et al., 2020) is also a prime example of this.

For the interactive Char-RNN study, we developed the LeapMotion interface, not because we believe this is the best mode of interaction for this medium. We developed it because we believe this is a starting point, that hopefully other researchers can follow through on. It acts as an example to demonstrate the vast number of possibilities with regards to interfaces for Deep Neural Network manipulation, an area which we believe is highly under-researchers.

For example, we also considered detecting facial features and mapping them to style weights. In other words, we imagined that different kinds of facial expressions could control the style of the text generated. A fully smiling face could correspond to the Dalai Lama style, while a frowning face could correspond to Trump. In a similar fashion, different styles could be assigned to eyebrows raised, lowered, looking angry, eyes closed, open etc. And then through various facial manipulations, the style of the text is altered in realtime. In conclusion, the interactive Char-RNN software that we developed, demonstrates perfectly what we were hoping to demonstrate with this study.

After this, we move onto a more complex and high-dimensional domain, pixel-based images. This will be the medium that we work with in the remainder of this thesis. We start in the next chapter looking at how image-based Deep Neural Networks learn. For this, we develop an interactive training software that trains in realtime on a live camera feed.

Footnotes

  1. section 1.3: Meaningful Human Control ↩

  2. section 1.4: Visual instruments: Realtime Continuous Control ↩

  3. section 2.1: Generative models ↩

  4. subsection 2.1.3: Latent manipulations ↩

  5. subsection 2.2.7: Char-RNN ↩

  6. subsection 2.2.7: Sketch-RNN (2017) ↩

  7. https://magenta.tensorflow.org/sketch-rnn-demo ↩

  8. subsection 2.3.17: Variational Auto-Encoders (VAE) ↩

  9. subsection 2.3.18: Deep Convolutional Generative Adversarial Networks (DCGAN) ↩

  10. subsection 2.3.10: Gradient descent and backpropagation ↩

  11. subsection 2.3.15: Convolutional Neural Networks (CNN) ↩

  12. https://rossgoodwin.com/ ↩

  13. https://www.decontextualize.com/ ↩

  14. https://milker.org/ ↩

Full-size image