# How can I get output data of a trained neural network?

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

This is the networks structure:

The following code should train the network with 1000 datasets:

After that, I try to draw a sine with this piece of code:

The output is quite disappointing, compared to a real sine wave:

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

Edit:

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

• Can you clarify what you mean by "real data"? – gung Aug 10 '15 at 12:41
• 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). – Christoph Bühler Aug 10 '15 at 12:43
• 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$. – Richard Hardy Aug 10 '15 at 13:20
• @RichardHardy I've just tried this. It does not seem to work, but thank you for the suggestion. – Christoph Bühler Aug 10 '15 at 13:29
• 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. – Richard Hardy Aug 10 '15 at 13:35

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