1
$\begingroup$

I'm new to relatively RNNs, and I'm trying to train generative and guessing neural networks to produce sequences of real numbers that look random. My architecture looks like this (each "circle" in the output is the adverserial network's guess for the generated circle vertically below it -- having seen only the terms before it):

Note that the adverserial network is rewarded for predicting outputs close to the true values, i.e. the loss function looks like tf.math.reduce_max((sequence - predictions) ** 2) (I have also tried reduce_mean).

I don't know if there's something obviously wrong with my architecture, but when I try to train this network (and I've added a reasonable number of layers), it doesn't really work very well.

If you look at the result of the last code block, you'll see that my generative neural network produces things like

  • [0.9907787, 0.9907827, 0.9907827, 0.9907827, 0.9907827, 0.9907827, 0.9907827, 0.9907827, 0.9907827, 0.9907827]

But it could easily improve itself by simply training to jump around more, since you'll observe that the adverserial network also predicts numbers very close to the given number (even when the sequence it is given to predict is one that jumps around a lot!).

What am I doing wrong?

$\endgroup$
1
  • $\begingroup$ If you are trying for purely random numbers, how do you determine what a "true" value would be to measure loss? $\endgroup$ Commented Jul 9, 2023 at 10:17

1 Answer 1

1
$\begingroup$

I think there are two problems with your network. The first one, always having very similar outputs, is the rather simple one. As it seems, your network suffers from the so-called, very common Mode Collapse problem. The attached link provides both an explanation and some potential remedy to that problem.

The second problem is more fundamental. You say that you want your network to produce random numbers. Or numbers that at least appear as such. However, once training is finished, your model is going to be a static function which will not change any further. Given the same input x, it will always produce the same output y. Consequently, unless the inputs to your network contain some randomness already or are, at least, always slightly dissimilar, you will not end up having a random generator. So, whether that is going to be useful will depend on your usecase. But if you make sure that the true random variable (like date&time) serves as input to the RNN and the RNN just translates this into some different format, that might work again. Just keep in mind that randomness can never arise out of a trained model.

$\endgroup$
4
  • $\begingroup$ Thanks, I'll have a look at your link. Regarding randomness -- I agree, but the point of my demonstration is to partially illustrate the fact that trained models, like human brains, are poor sources of entropy. Nonetheless, I would expect that they can be as good as human brains are, and at least produce sequences that aren't completely trivial to predict. $\endgroup$ Commented Jun 24, 2020 at 5:15
  • 2
    $\begingroup$ A RNN could theoretically emulate a simple PRNG, and I think that would serve OP's need. PRNGs are also deterministic and work with a starting seed value. The OP wants to generate sequences that look random, they have not asked for "true random", so I think a PRNG would be OK. However, I don't know how to create an RNN that could behave like a PRNG - what architecture and training would be likely to work. $\endgroup$ Commented Jul 23, 2020 at 19:53
  • $\begingroup$ The discriminator is going to have all the same data the generator does, so it should be able to predict all the numbers if it just copies the generator. But one hope is that perhaps it won't be able to converge towards the same weights just by seeing the output. $\endgroup$ Commented Jul 30, 2021 at 12:57
  • $\begingroup$ I suspect a fundamental problem here is how you determine what the correct outputs should be so that you can measure loss. It's a very subjective problem. Could the next number be equal to the last? Certainly. Could it be much higher? Sure. Much lower? Absolutely. It sounds like OP is trying to capture the impression someone would have looking at the data. $\endgroup$ Commented Jul 9, 2023 at 10:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .