Think of a generative network generating animal names.

It's been trained on a set of animal names so this shouldn't be too hard.

But say I want to generate 10 animal names. First I run the network and it produces ZEBRA. Next it produces HORSE. Next it produces HORSE again. This is no good.

I need a way to supress previous answers.

Since I know the patterns of weights that produced the words ZEBRA and HORSE, can I used this knowledge to tweek the network in able to give me a new unique result.

(I don't mean I want all 10 answers at once! I mean I want to run the network again and again but get different results each time.)

In otherwords I want to supress the maxima that gave me the previous answers.

(This task seems quite easy for a human who can list 20-30 animal names without repetition. I'm not sure if this is because the previous animal names are stored in the short term memory or the synapses for the previous animals are supressed somehow).


I need a way to supress previous answers.

The answer to the question depends on the particular network that you are using. What kind of generative model is it? GAN? Autoencoder? Seq2Seq RNN?

Having said that, if your network keeps outputting the same result, this is usually referred to as "mode collapse", which is typical for GANs. If your network is a GAN, it may be worth exploring the Wasserstein Loss that effectively helps you deal with mode collapse.

Generally, a standard path to achieve diversity (and non-repetitive results) in the output of a generative network is to augment your training dataset. Augmentation refers to representing the same data in different ways. In the context of animal pictures, imagine it as providing different pictures of zebras or horses, from different angles or under different light conditions etc.

Also make sure that your training dataset is balanced, i.e. all classes are represented equally in the training set, otherwise the result will be biased.

If you are using a seq2seq network which generates string names of animals, you usually sample those names character by character. There are different sampling strategies in this case, such as greedy sampling (always the most probable character), multinomial sampling (beam search) which can also have temperature scaling. These strategies yield different results and are worth exploring. A very important metric that enhances the diversity of the output of such a network, is the likelihood of a sampled sequence (or its negative log-likelihood). You want to include this likelihood in your loss function to make sure you "push" the network to sample everything in its reach with equal probability. This is explained nicely in this publication and this publication, which use string representations of molecules that are analogous to your animal names task.

If you are using an autoencoder as a generative network, you can combine it with an optimization algorithm, such as particle swarm optimizer, to navigate within its latent space and automatically sample diverse solutions. The key here is the cost function of the optimization algorithm, because inside it you need to penalize repetitive answers. Similar performance can be achieved using reinforcement learning and a likewise penalizing scoring function.

I'm not sure if this is because the previous animal names are stored in the short term memory or the synapses for the previous animals are supressed somehow

If you are using stateless LSTM units, the memory is reset between independent predictions. If you use stateful LSTM units, previous predictions affect next predictions.

I realize that my answer covered many different approaches, however it may provide you with different directions to explore.

| improve this answer | |
  • $\begingroup$ That's interesting that I might augment the Generative Network with and RNN so it a can output sequences of results. And then train the RNN to give higher probabilities to results that are different from each other! Good idea. The RNN would have to know some measure of differnce though.... With an LSTM it might be possible to train it to output quite long sequences of unique results. Although I'm not sure RNN and LSTM are good at determining differences. $\endgroup$ – zooby Jan 9 at 14:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.