My neural network, which uses the back-propagation technique and the sigmoid activation function, should 'learn' the sine function.

This is the networks structure: enter image description here

The following code should train the network with 1000 datasets:

enter image description here

After that, I try to draw a sine with this piece of code: enter image description here

The output is quite disappointing, compared to a real sine wave: enter image description here

I hope, someone could give me a hint. Thank you.


The problem was solved (see answer by Richard Hardy). I made this interactive website for testing the network: http://norizon.li/repo/neural-net/

  • $\begingroup$ Can you clarify what you mean by "real data"? $\endgroup$ – gung - Reinstate Monica Aug 10 '15 at 12:41
  • $\begingroup$ By real data, I mean the output value. In this test case, I am using x as input and the output should be sin(x). $\endgroup$ – Christoph Bühler Aug 10 '15 at 12:43
  • $\begingroup$ Have you considered transforming your data to fit into the [0,1] interval? $\frac{sin(x)+1}{2}$ will fit into [0,1] for any $x$. $\endgroup$ – Richard Hardy Aug 10 '15 at 13:20
  • $\begingroup$ @RichardHardy I've just tried this. It does not seem to work, but thank you for the suggestion. $\endgroup$ – Christoph Bühler Aug 10 '15 at 13:29
  • $\begingroup$ The transformation itself must work, so perhaps the problem lies elsewhere. Could you rephrase your question and/or give more details on what you are doing (step by step)? Perhaps then it will be easier to see what the trouble is. $\endgroup$ – Richard Hardy Aug 10 '15 at 13:35

Considered transforming your data to fit into the [0,1] interval.

For the $\operatorname{sin}(x)$ case, $\frac{ \operatorname{sin}(x) + 1}{ 2 }$ will fit into [0,1] for any $x$.


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.