title: Tensorflow: Neural Network does not converge
body: <p>I am currently working to implement a Neural Network, which should predict a function in the range X[0,) and Y[0,).</p>
  
  <p>I decided to implement the Network using Tensorflow. Moreover, I decided to use 2 layers, where the first has 50 and the second 30 nodes. As activation functions, I use the sigmoid for the hidden layers and the softplus for the output layer (to be able to get outputs larger than 1).</p>
  
  <p>This setup works well for problems like a scaled sinus function between 0 and 2 (for X and Y). However, when applying this to real data, it does not seem to converge.</p>
  
  <p>Here the code I wrote:</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  import itertools
  import tensorflow as tf
  import json
  
  train = []
  datax = []
  datay = []
  data = []
  
  def grouper(n, iterable):
      it = iter(iterable)
      while True:
         chunk = tuple(itertools.islice(it, n))
         if not chunk:
             return
         yield chunk
  
  # Load data from string into list
  points = json.loads('[["445.0", "38.0"], ["416.0", "25.0"], ["439.0", "40.0"], ["450.0", "41.0"], ["448.0", "39.0"], ["467.0", "32.0"], ["419.0", "29.0"], ["430.0", "39.0"], ["459.0", "42.0"], ["482.0", "36.0"], ["477.0", "38.0"], ["449.0", "41.0"], ["465.0", "39.0"], ["464.0", "44.0"], ["431.0", "41.0"], ["399.0", "40.0"], ["369.0", "40.0"], ["377.0", "48.0"], ["403.0", "38.0"], ["374.0", "40.0"], ["393.0", "43.0"], ["368.0", "41.0"], ["340.0", "41.0"], ["357.0", "37.0"], ["356.0", "36.0"], ["397.0", "44.0"], ["388.0", "45.0"], ["355.0", "39.0"], ["392.0", "44.0"], ["346.0", "40.0"], ["462.0", "45.0"], ["426.0", "34.0"], ["481.0", "35.0"], ["454.0", "45.0"], ["470.0", "33.0"], ["452.0", "38.0"], ["444.0", "35.0"], ["475.0", "38.0"], ["458.0", "42.0"], ["461.0", "42.0"], ["483.0", "39.0"], ["457.0", "43.0"], ["447.0", "36.0"], ["417.0", "26.0"], ["460.0", "43.0"], ["455.0", "44.0"], ["427.0", "36.0"], ["415.0", "22.0"], ["456.0", "43.0"], ["418.0", "29.0"], ["606.0", "41.0"], ["580.0", "43.0"], ["666.0", "40.0"], ["619.0", "40.0"], ["608.0", "40.0"], ["627.0", "41.0"], ["684.0", "41.0"], ["624.0", "45.0"], ["612.0", "39.0"], ["618.0", "42.0"], ["598.0", "47.0"], ["599.0", "45.0"], ["603.0", "43.0"], ["592.0", "42.0"], ["585.0", "42.0"], ["565.0", "49.0"], ["640.0", "38.0"], ["613.0", "41.0"], ["588.0", "39.0"], ["696.0", "41.0"], ["90.0", "52.0"], ["104.0", "55.0"], ["71.0", "55.0"], ["85.0", "48.0"], ["94.0", "49.0"], ["597.0", "44.0"], ["646.0", "40.0"], ["672.0", "40.0"], ["685.0", "44.0"], ["667.0", "39.0"], ["654.0", "39.0"], ["668.0", "39.0"], ["651.0", "41.0"], ["675.0", "40.0"], ["633.0", "40.0"], ["631.0", "39.0"], ["689.0", "41.0"], ["699.0", "37.0"], ["660.0", "40.0"], ["626.0", "41.0"], ["587.0", "40.0"], ["582.0", "39.0"], ["607.0", "38.0"], ["596.0", "45.0"], ["571.0", "45.0"], ["579.0", "44.0"], ["556.0", "42.0"], ["560.0", "46.0"], ["610.0", "40.0"], ["601.0", "45.0"], ["557.0", "41.0"], ["616.0", "42.0"], ["594.0", "46.0"], ["562.0", "45.0"], ["590.0", "40.0"], ["577.0", "42.0"], ["574.0", "39.0"], ["622.0", "42.0"], ["570.0", "44.0"], ["563.0", "47.0"], ["611.0", "44.0"], ["593.0", "47.0"], ["558.0", "44.0"], ["561.0", "44.0"], ["600.0", "45.0"], ["658.0", "42.0"], ["657.0", "43.0"], ["638.0", "41.0"], ["691.0", "43.0"], ["697.0", "41.0"], ["625.0", "41.0"], ["615.0", "39.0"], ["678.0", "42.0"], ["628.0", "37.0"], ["663.0", "37.0"], ["632.0", "37.0"], ["659.0", "42.0"], ["595.0", "47.0"], ["583.0", "39.0"], ["568.0", "43.0"], ["609.0", "44.0"], ["614.0", "40.0"], ["620.0", "42.0"], ["617.0", "47.0"], ["564.0", "48.0"], ["572.0", "41.0"], ["584.0", "40.0"], ["566.0", "40.0"], ["559.0", "44.0"], ["576.0", "43.0"], ["569.0", "42.0"], ["621.0", "44.0"], ["589.0", "40.0"], ["602.0", "46.0"], ["581.0", "43.0"], ["575.0", "40.0"], ["578.0", "43.0"], ["623.0", "43.0"], ["567.0", "44.0"], ["605.0", "42.0"], ["591.0", "40.0"], ["604.0", "40.0"], ["5.0", "50.0"], ["30.0", "66.0"], ["27.0", "60.0"], ["44.0", "65.0"], ["16.0", "61.0"], ["25.0", "61.0"], ["29.0", "71.0"], ["14.0", "61.0"], ["0.0", "40.0"], ["24.0", "59.0"], ["693.0", "45.0"], ["681.0", "41.0"], ["19.0", "65.0"], ["655.0", "39.0"], ["652.0", "43.0"], ["12.0", "65.0"], ["51.0", "62.0"], ["50.0", "66.0"], ["40.0", "75.0"], ["687.0", "44.0"], ["643.0", "40.0"], ["649.0", "41.0"], ["686.0", "44.0"], ["75.0", "55.0"], ["33.0", "68.0"], ["86.0", "46.0"], ["108.0", "52.0"], ["39.0", "65.0"], ["41.0", "69.0"], ["98.0", "54.0"], ["112.0", "53.0"], ["95.0", "46.0"], ["653.0", "40.0"], ["698.0", "40.0"], ["677.0", "39.0"], ["690.0", "44.0"], ["637.0", "37.0"], ["118.0", "53.0"], ["648.0", "42.0"], ["65.0", "56.0"], ["641.0", "41.0"], ["661.0", "39.0"], ["674.0", "40.0"], ["635.0", "38.0"], ["688.0", "44.0"], ["679.0", "42.0"], ["665.0", "38.0"], ["656.0", "40.0"], ["680.0", "39.0"], ["662.0", "39.0"], ["634.0", "39.0"], ["650.0", "41.0"], ["670.0", "41.0"], ["644.0", "43.0"], ["639.0", "39.0"], ["682.0", "43.0"], ["636.0", "39.0"], ["669.0", "40.0"], ["647.0", "40.0"], ["37.0", "65.0"], ["20.0", "66.0"], ["48.0", "66.0"], ["46.0", "65.0"], ["3.0", "44.0"], ["9.0", "62.0"], ["1.0", "45.0"], ["35.0", "59.0"], ["47.0", "68.0"], ["28.0", "68.0"], ["68.0", "56.0"], ["91.0", "47.0"], ["78.0", "48.0"], ["692.0", "44.0"], ["642.0", "40.0"], ["695.0", "42.0"], ["645.0", "41.0"], ["694.0", "42.0"], ["119.0", "52.0"], ["74.0", "54.0"], ["99.0", "53.0"], ["70.0", "55.0"], ["120.0", "51.0"], ["88.0", "52.0"], ["73.0", "61.0"], ["102.0", "57.0"], ["59.0", "61.0"], ["87.0", "48.0"], ["110.0", "54.0"], ["93.0", "49.0"], ["54.0", "68.0"], ["630.0", "40.0"], ["629.0", "40.0"], ["673.0", "39.0"], ["683.0", "40.0"], ["11.0", "65.0"], ["13.0", "66.0"], ["36.0", "63.0"], ["7.0", "60.0"], ["8.0", "61.0"], ["38.0", "63.0"], ["32.0", "60.0"], ["22.0", "62.0"], ["31.0", "69.0"], ["15.0", "62.0"], ["21.0", "66.0"], ["49.0", "63.0"], ["23.0", "56.0"], ["664.0", "38.0"], ["26.0", "64.0"], ["42.0", "67.0"], ["6.0", "63.0"], ["18.0", "62.0"], ["10.0", "64.0"], ["4.0", "42.0"], ["2.0", "44.0"], ["43.0", "68.0"], ["17.0", "64.0"], ["34.0", "64.0"], ["45.0", "62.0"], ["310.0", "49.0"], ["293.0", "40.0"], ["297.0", "41.0"], ["301.0", "40.0"], ["285.0", "48.0"], ["295.0", "40.0"], ["313.0", "42.0"], ["294.0", "40.0"], ["333.0", "38.0"], ["290.0", "42.0"], ["292.0", "41.0"], ["306.0", "42.0"], ["275.0", "40.0"], ["269.0", "40.0"], ["327.0", "28.0"], ["281.0", "43.0"], ["321.0", "44.0"], ["96.0", "48.0"], ["109.0", "55.0"], ["58.0", "64.0"], ["72.0", "61.0"], ["331.0", "30.0"], ["299.0", "39.0"], ["318.0", "45.0"], ["286.0", "45.0"], ["288.0", "43.0"], ["336.0", "38.0"], ["302.0", "42.0"], ["284.0", "48.0"], ["328.0", "26.0"], ["312.0", "45.0"], ["311.0", "47.0"], ["324.0", "24.0"], ["307.0", "42.0"], ["271.0", "39.0"], ["339.0", "41.0"], ["335.0", "36.0"], ["283.0", "46.0"], ["287.0", "45.0"], ["329.0", "30.0"], ["323.0", "25.0"], ["305.0", "43.0"], ["308.0", "45.0"], ["107.0", "49.0"], ["100.0", "54.0"], ["97.0", "53.0"], ["92.0", "49.0"], ["114.0", "64.0"], ["63.0", "53.0"], ["105.0", "49.0"], ["57.0", "66.0"], ["113.0", "55.0"], ["80.0", "50.0"], ["56.0", "66.0"], ["117.0", "55.0"], ["67.0", "62.0"], ["115.0", "62.0"], ["55.0", "64.0"], ["69.0", "56.0"], ["314.0", "36.0"], ["280.0", "43.0"], ["326.0", "25.0"], ["277.0", "40.0"], ["337.0", "39.0"], ["338.0", "38.0"], ["325.0", "26.0"], ["303.0", "44.0"], ["332.0", "33.0"], ["272.0", "39.0"], ["296.0", "41.0"], ["298.0", "38.0"], ["270.0", "38.0"], ["309.0", "45.0"], ["268.0", "44.0"], ["330.0", "29.0"], ["289.0", "42.0"], ["319.0", "42.0"], ["315.0", "37.0"], ["276.0", "36.0"], ["278.0", "43.0"], ["89.0", "50.0"], ["81.0", "51.0"], ["122.0", "54.0"], ["121.0", "54.0"], ["66.0", "61.0"], ["84.0", "47.0"], ["76.0", "52.0"], ["106.0", "51.0"], ["279.0", "41.0"], ["316.0", "38.0"], ["322.0", "20.0"], ["320.0", "43.0"], ["282.0", "46.0"], ["300.0", "39.0"], ["273.0", "34.0"], ["304.0", "45.0"], ["334.0", "38.0"], ["291.0", "42.0"], ["274.0", "39.0"], ["317.0", "39.0"], ["53.0", "59.0"], ["101.0", "54.0"], ["676.0", "43.0"], ["671.0", "40.0"], ["123.0", "51.0"], ["64.0", "52.0"], ["60.0", "66.0"], ["77.0", "49.0"], ["111.0", "56.0"], ["83.0", "51.0"], ["116.0", "59.0"], ["61.0", "66.0"], ["79.0", "49.0"], ["62.0", "60.0"], ["82.0", "53.0"], ["103.0", "57.0"], ["52.0", "56.0"], ["573.0", "41.0"], ["586.0", "41.0"], ["195.0", "43.0"], ["136.0", "54.0"], ["127.0", "49.0"], ["124.0", "48.0"], ["147.0", "52.0"], ["180.0", "46.0"], ["144.0", "47.0"], ["148.0", "51.0"], ["172.0", "47.0"], ["160.0", "49.0"], ["159.0", "51.0"], ["184.0", "41.0"], ["166.0", "60.0"], ["178.0", "46.0"], ["516.0", "39.0"], ["507.0", "45.0"], ["149.0", "50.0"], ["165.0", "56.0"], ["183.0", "43.0"], ["130.0", "53.0"], ["193.0", "37.0"], ["155.0", "52.0"], ["132.0", "57.0"], ["154.0", "51.0"], ["231.0", "46.0"], ["167.0", "57.0"], ["146.0", "49.0"], ["176.0", "47.0"], ["174.0", "50.0"], ["126.0", "48.0"], ["150.0", "52.0"], ["157.0", "51.0"], ["191.0", "42.0"], ["153.0", "56.0"], ["186.0", "48.0"], ["156.0", "48.0"], ["152.0", "53.0"], ["190.0", "44.0"], ["133.0", "56.0"], ["179.0", "46.0"], ["161.0", "52.0"], ["185.0", "44.0"], ["182.0", "44.0"], ["181.0", "43.0"], ["135.0", "51.0"], ["169.0", "52.0"], ["141.0", "46.0"], ["219.0", "45.0"], ["220.0", "44.0"], ["226.0", "44.0"], ["218.0", "47.0"], ["196.0", "45.0"], ["214.0", "40.0"], ["229.0", "46.0"], ["212.0", "39.0"], ["216.0", "40.0"], ["200.0", "41.0"], ["215.0", "42.0"], ["235.0", "45.0"], ["252.0", "44.0"], ["240.0", "44.0"], ["210.0", "43.0"], ["250.0", "43.0"], ["266.0", "41.0"], ["206.0", "45.0"], ["223.0", "45.0"], ["257.0", "41.0"], ["248.0", "45.0"], ["213.0", "41.0"], ["202.0", "46.0"], ["207.0", "42.0"], ["267.0", "42.0"], ["221.0", "46.0"], ["199.0", "43.0"], ["251.0", "46.0"], ["253.0", "46.0"], ["261.0", "41.0"], ["208.0", "42.0"], ["243.0", "44.0"], ["228.0", "45.0"], ["258.0", "40.0"], ["262.0", "40.0"], ["237.0", "48.0"], ["238.0", "42.0"], ["217.0", "46.0"], ["230.0", "44.0"], ["227.0", "43.0"], ["263.0", "45.0"], ["241.0", "43.0"], ["236.0", "46.0"], ["224.0", "44.0"], ["234.0", "42.0"], ["204.0", "48.0"], ["247.0", "45.0"], ["245.0", "44.0"], ["197.0", "43.0"], ["225.0", "43.0"], ["260.0", "40.0"], ["259.0", "41.0"], ["232.0", "46.0"], ["256.0", "41.0"], ["242.0", "45.0"], ["239.0", "44.0"], ["222.0", "46.0"], ["201.0", "43.0"], ["209.0", "41.0"], ["255.0", "41.0"], ["205.0", "49.0"], ["246.0", "43.0"], ["233.0", "43.0"], ["198.0", "43.0"], ["249.0", "42.0"], ["264.0", "42.0"], ["211.0", "40.0"], ["203.0", "46.0"], ["265.0", "39.0"], ["244.0", "42.0"], ["254.0", "42.0"], ["128.0", "52.0"], ["187.0", "47.0"], ["177.0", "51.0"], ["137.0", "53.0"], ["134.0", "53.0"], ["142.0", "52.0"], ["170.0", "48.0"], ["139.0", "47.0"], ["140.0", "47.0"], ["162.0", "52.0"], ["171.0", "48.0"], ["173.0", "51.0"], ["531.0", "44.0"], ["550.0", "48.0"], ["552.0", "46.0"], ["486.0", "37.0"], ["553.0", "42.0"], ["526.0", "46.0"], ["502.0", "43.0"], ["524.0", "44.0"], ["537.0", "44.0"], ["498.0", "39.0"], ["495.0", "36.0"], ["485.0", "36.0"], ["535.0", "45.0"], ["533.0", "45.0"], ["527.0", "45.0"], ["543.0", "47.0"], ["505.0", "41.0"], ["538.0", "46.0"], ["541.0", "43.0"], ["192.0", "40.0"], ["151.0", "53.0"], ["168.0", "48.0"], ["554.0", "42.0"], ["518.0", "41.0"], ["189.0", "47.0"], ["164.0", "48.0"], ["145.0", "47.0"], ["143.0", "48.0"], ["158.0", "53.0"], ["138.0", "48.0"], ["188.0", "45.0"], ["129.0", "47.0"], ["131.0", "57.0"], ["125.0", "47.0"], ["163.0", "53.0"], ["194.0", "36.0"], ["175.0", "52.0"], ["525.0", "48.0"], ["519.0", "43.0"], ["503.0", "40.0"], ["555.0", "43.0"], ["515.0", "41.0"], ["520.0", "45.0"], ["517.0", "43.0"], ["523.0", "45.0"], ["534.0", "43.0"], ["510.0", "46.0"], ["547.0", "48.0"], ["489.0", "39.0"], ["551.0", "45.0"], ["500.0", "44.0"], ["492.0", "39.0"], ["506.0", "44.0"], ["529.0", "43.0"], ["491.0", "40.0"], ["546.0", "50.0"], ["493.0", "41.0"], ["508.0", "45.0"], ["545.0", "48.0"], ["536.0", "45.0"], ["490.0", "40.0"], ["522.0", "48.0"], ["513.0", "44.0"], ["514.0", "43.0"], ["488.0", "40.0"], ["539.0", "49.0"], ["499.0", "41.0"], ["509.0", "47.0"], ["511.0", "46.0"], ["494.0", "38.0"], ["497.0", "38.0"], ["544.0", "48.0"], ["496.0", "41.0"], ["501.0", "39.0"], ["487.0", "35.0"], ["540.0", "44.0"], ["521.0", "46.0"], ["512.0", "45.0"], ["528.0", "42.0"], ["532.0", "45.0"], ["542.0", "44.0"], ["530.0", "43.0"], ["504.0", "41.0"], ["548.0", "48.0"], ["484.0", "37.0"], ["549.0", "47.0"], ["453.0", "39.0"], ["479.0", "37.0"], ["434.0", "41.0"], ["428.0", "38.0"], ["468.0", "31.0"], ["474.0", "38.0"], ["423.0", "32.0"], ["422.0", "31.0"], ["435.0", "41.0"], ["441.0", "39.0"], ["463.0", "45.0"], ["352.0", "42.0"], ["354.0", "43.0"], ["350.0", "40.0"], ["360.0", "39.0"], ["438.0", "41.0"], ["451.0", "41.0"], ["472.0", "41.0"], ["440.0", "40.0"], ["383.0", "46.0"], ["469.0", "32.0"], ["437.0", "40.0"], ["476.0", "39.0"], ["412.0", "19.0"], ["413.0", "26.0"], ["342.0", "41.0"], ["473.0", "40.0"], ["401.0", "39.0"], ["378.0", "47.0"], ["379.0", "47.0"], ["405.0", "39.0"], ["480.0", "34.0"], ["421.0", "29.0"], ["466.0", "35.0"], ["420.0", "29.0"], ["425.0", "33.0"], ["407.0", "37.0"], ["389.0", "44.0"], ["372.0", "39.0"], ["373.0", "42.0"], ["400.0", "38.0"], ["375.0", "42.0"], ["390.0", "44.0"], ["408.0", "36.0"], ["376.0", "45.0"], ["411.0", "9.0"], ["362.0", "40.0"], ["386.0", "44.0"], ["398.0", "45.0"], ["396.0", "45.0"], ["345.0", "42.0"], ["361.0", "40.0"], ["348.0", "41.0"], ["381.0", "44.0"], ["341.0", "42.0"], ["446.0", "38.0"], ["424.0", "32.0"], ["429.0", "38.0"], ["471.0", "36.0"], ["394.0", "43.0"], ["359.0", "39.0"], ["358.0", "39.0"], ["410.0", "37.0"], ["365.0", "37.0"], ["344.0", "42.0"], ["351.0", "39.0"], ["363.0", "39.0"], ["364.0", "39.0"], ["409.0", "38.0"], ["349.0", "42.0"], ["387.0", "44.0"], ["395.0", "45.0"], ["343.0", "39.0"], ["382.0", "47.0"], ["367.0", "41.0"], ["391.0", "46.0"], ["402.0", "38.0"], ["347.0", "38.0"], ["353.0", "42.0"], ["371.0", "42.0"], ["370.0", "40.0"], ["380.0", "42.0"], ["384.0", "43.0"], ["404.0", "41.0"], ["414.0", "23.0"], ["442.0", "42.0"], ["366.0", "41.0"], ["433.0", "41.0"], ["478.0", "36.0"], ["443.0", "40.0"], ["406.0", "38.0"], ["385.0", "43.0"], ["436.0", "41.0"], ["432.0", "43.0"], ["1252.0", "21.0"], ["1108.0", "33.0"], ["1101.0", "31.0"], ["1118.0", "36.0"], ["1102.0", "33.0"], ["1087.0", "26.0"], ["1061.0", "34.0"], ["1121.0", "30.0"], ["1077.0", "25.0"], ["1126.0", "30.0"], ["1096.0", "24.0"], ["1100.0", "30.0"], ["1110.0", "33.0"], ["1094.0", "28.0"], ["1062.0", "33.0"], ["1083.0", "25.0"], ["1127.0", "30.0"], ["1114.0", "35.0"], ["1085.0", "28.0"], ["1119.0", "35.0"], ["1271.0", "24.0"], ["1269.0", "25.0"], ["1265.0", "24.0"], ["1257.0", "24.0"], ["1264.0", "22.0"], ["1262.0", "23.0"], ["1274.0", "24.0"], ["1268.0", "25.0"], ["1273.0", "24.0"], ["1272.0", "23.0"], ["1248.0", "18.0"], ["1261.0", "22.0"], ["1267.0", "25.0"], ["1254.0", "20.0"], ["1253.0", "21.0"], ["1255.0", "22.0"], ["1249.0", "19.0"], ["1260.0", "22.0"], ["1258.0", "24.0"], ["1263.0", "22.0"], ["1256.0", "23.0"], ["1259.0", "22.0"], ["1270.0", "25.0"], ["1275.0", "25.0"], ["1250.0", "19.0"], ["1266.0", "24.0"], ["1246.0", "17.0"], ["1247.0", "20.0"], ["1251.0", "20.0"], ["1203.0", "25.0"], ["1198.0", "26.0"], ["1199.0", "25.0"], ["1193.0", "25.0"], ["1194.0", "25.0"], ["1191.0", "23.0"], ["1170.0", "23.0"], ["1145.0", "28.0"], ["1195.0", "24.0"], ["1196.0", "25.0"], ["1174.0", "23.0"], ["1182.0", "22.0"], ["1146.0", "29.0"], ["1159.0", "24.0"], ["1183.0", "24.0"], ["1134.0", "33.0"], ["1139.0", "28.0"], ["1155.0", "26.0"], ["1160.0", "26.0"], ["1151.0", "25.0"], ["1163.0", "23.0"], ["1179.0", "25.0"], ["1190.0", "25.0"], ["1202.0", "25.0"], ["1142.0", "24.0"], ["1158.0", "25.0"], ["1169.0", "23.0"], ["1164.0", "25.0"], ["1154.0", "26.0"], ["1175.0", "24.0"], ["1161.0", "22.0"], ["1152.0", "23.0"], ["1133.0", "32.0"], ["1137.0", "28.0"], ["1153.0", "26.0"], ["1184.0", "24.0"], ["1201.0", "25.0"], ["1177.0", "24.0"], ["1178.0", "25.0"], ["1176.0", "24.0"], ["1156.0", "23.0"], ["1141.0", "29.0"], ["1173.0", "22.0"], ["1166.0", "23.0"], ["1140.0", "29.0"], ["1150.0", "24.0"], ["1192.0", "24.0"], ["1180.0", "25.0"], ["1135.0", "31.0"], ["1138.0", "30.0"], ["1188.0", "25.0"], ["1172.0", "24.0"], ["1165.0", "24.0"], ["1136.0", "31.0"], ["1186.0", "25.0"], ["1149.0", "26.0"], ["1167.0", "24.0"], ["1147.0", "28.0"], ["1181.0", "24.0"], ["1168.0", "24.0"], ["1157.0", "25.0"], ["1189.0", "24.0"], ["1144.0", "27.0"], ["1185.0", "24.0"], ["1197.0", "25.0"], ["1069.0", "27.0"], ["1068.0", "28.0"], ["1187.0", "26.0"], ["1200.0", "25.0"], ["1143.0", "25.0"], ["1132.0", "34.0"], ["1148.0", "27.0"], ["1162.0", "23.0"], ["1171.0", "24.0"], ["1070.0", "27.0"], ["1116.0", "34.0"], ["1084.0", "27.0"], ["1064.0", "32.0"], ["1071.0", "26.0"], ["1073.0", "29.0"], ["1122.0", "31.0"], ["1104.0", "31.0"], ["1098.0", "29.0"], ["1113.0", "34.0"], ["1080.0", "27.0"], ["1106.0", "30.0"], ["1120.0", "33.0"], ["1072.0", "27.0"], ["1082.0", "26.0"], ["1123.0", "34.0"], ["1063.0", "33.0"], ["1117.0", "35.0"], ["1099.0", "29.0"], ["1115.0", "34.0"], ["1109.0", "34.0"], ["1079.0", "27.0"], ["1067.0", "30.0"], ["1095.0", "26.0"], ["1092.0", "29.0"], ["1078.0", "26.0"], ["1089.0", "28.0"], ["1103.0", "32.0"], ["1129.0", "31.0"], ["1086.0", "27.0"], ["1097.0", "27.0"], ["1130.0", "31.0"], ["1075.0", "25.0"], ["1093.0", "30.0"], ["1091.0", "29.0"], ["1107.0", "34.0"], ["1060.0", "35.0"], ["1125.0", "30.0"], ["1105.0", "31.0"], ["1111.0", "33.0"], ["1090.0", "27.0"], ["1112.0", "33.0"], ["1076.0", "27.0"], ["1131.0", "32.0"], ["1066.0", "30.0"], ["1074.0", "27.0"], ["1081.0", "27.0"], ["1124.0", "31.0"], ["1128.0", "30.0"], ["1065.0", "31.0"], ["1088.0", "27.0"], ["1290.0", "24.0"], ["1279.0", "24.0"], ["808.0", "27.0"], ["783.0", "32.0"], ["822.0", "31.0"], ["805.0", "30.0"], ["842.0", "27.0"], ["1284.0", "21.0"], ["1296.0", "27.0"], ["1281.0", "22.0"], ["1291.0", "25.0"], ["1278.0", "25.0"], ["1283.0", "21.0"], ["1298.0", "27.0"], ["1282.0", "22.0"], ["1288.0", "26.0"], ["1301.0", "23.0"], ["1303.0", "24.0"], ["1297.0", "29.0"], ["1286.0", "22.0"], ["814.0", "29.0"], ["788.0", "27.0"], ["836.0", "26.0"], ["800.0", "30.0"], ["787.0", "29.0"], ["804.0", "29.0"], ["823.0", "28.0"], ["843.0", "28.0"], ["839.0", "29.0"], ["797.0", "32.0"], ["796.0", "32.0"], ["816.0", "29.0"], ["831.0", "27.0"], ["775.0", "33.0"], ["833.0", "27.0"], ["828.0", "27.0"], ["776.0", "34.0"], ["772.0", "35.0"], ["779.0", "30.0"], ["811.0", "27.0"], ["782.0", "29.0"], ["799.0", "29.0"], ["837.0", "26.0"], ["793.0", "31.0"], ["780.0", "29.0"], ["778.0", "32.0"], ["827.0", "27.0"], ["790.0", "28.0"], ["781.0", "29.0"], ["820.0", "29.0"], ["841.0", "28.0"], ["812.0", "27.0"], ["786.0", "30.0"], ["806.0", "30.0"], ["794.0", "32.0"], ["774.0", "31.0"], ["791.0", "29.0"], ["821.0", "30.0"], ["803.0", "29.0"], ["807.0", "30.0"], ["784.0", "29.0"], ["801.0", "31.0"], ["773.0", "34.0"], ["802.0", "30.0"], ["777.0", "31.0"], ["826.0", "26.0"], ["825.0", "27.0"], ["819.0", "30.0"], ["834.0", "25.0"], ["813.0", "28.0"], ["810.0", "28.0"], ["795.0", "30.0"], ["830.0", "28.0"], ["817.0", "29.0"], ["815.0", "29.0"], ["785.0", "30.0"], ["792.0", "30.0"], ["789.0", "28.0"], ["798.0", "30.0"], ["840.0", "30.0"], ["832.0", "27.0"], ["824.0", "27.0"], ["835.0", "25.0"], ["809.0", "28.0"], ["838.0", "28.0"], ["829.0", "29.0"], ["818.0", "30.0"], ["1042.0", "36.0"], ["1040.0", "35.0"], ["1039.0", "32.0"], ["1033.0", "39.0"], ["1054.0", "32.0"], ["1005.0", "26.0"], ["1009.0", "33.0"], ["1058.0", "33.0"], ["990.0", "26.0"], ["1027.0", "35.0"], ["1008.0", "31.0"], ["1049.0", "31.0"], ["1045.0", "32.0"], ["991.0", "25.0"], ["994.0", "25.0"], ["1057.0", "33.0"], ["1300.0", "25.0"], ["1305.0", "23.0"], ["1304.0", "23.0"], ["1276.0", "24.0"], ["1277.0", "25.0"], ["1285.0", "21.0"], ["1302.0", "24.0"], ["1299.0", "26.0"], ["1289.0", "25.0"], ["1295.0", "27.0"], ["1293.0", "25.0"], ["1294.0", "26.0"], ["1306.0", "24.0"], ["1292.0", "23.0"], ["1280.0", "23.0"], ["1287.0", "25.0"], ["1044.0", "30.0"], ["989.0", "27.0"], ["997.0", "29.0"], ["1004.0", "28.0"], ["999.0", "27.0"], ["1031.0", "35.0"], ["1012.0", "28.0"], ["1048.0", "34.0"], ["993.0", "26.0"], ["1037.0", "35.0"], ["1034.0", "38.0"], ["1050.0", "33.0"], ["1003.0", "29.0"], ["1036.0", "36.0"], ["1041.0", "36.0"], ["1018.0", "34.0"], ["992.0", "25.0"], ["1021.0", "36.0"], ["1026.0", "33.0"], ["1007.0", "32.0"], ["1006.0", "30.0"], ["1028.0", "34.0"], ["1022.0", "34.0"], ["1043.0", "32.0"], ["1014.0", "30.0"], ["998.0", "29.0"], ["1051.0", "33.0"], ["1019.0", "37.0"], ["1053.0", "32.0"], ["1013.0", "28.0"], ["1059.0", "33.0"], ["1015.0", "33.0"], ["1017.0", "33.0"], ["1055.0", "32.0"], ["1000.0", "30.0"], ["1011.0", "32.0"], ["1035.0", "37.0"], ["1016.0", "32.0"], ["1001.0", "31.0"], ["1052.0", "33.0"], ["1010.0", "33.0"], ["1047.0", "34.0"], ["996.0", "28.0"], ["988.0", "28.0"], ["1024.0", "33.0"], ["1038.0", "34.0"], ["1025.0", "33.0"], ["1056.0", "32.0"], ["995.0", "27.0"], ["1032.0", "35.0"], ["1020.0", "38.0"], ["1030.0", "34.0"], ["1023.0", "31.0"], ["845.0", "26.0"], ["1002.0", "31.0"], ["1046.0", "36.0"], ["1029.0", "34.0"], ["895.0", "23.0"], ["858.0", "24.0"], ["908.0", "24.0"], ["853.0", "27.0"], ["903.0", "24.0"], ["878.0", "25.0"], ["904.0", "25.0"], ["910.0", "28.0"], ["855.0", "25.0"], ["867.0", "24.0"], ["848.0", "28.0"], ["844.0", "29.0"], ["884.0", "26.0"], ["852.0", "28.0"], ["846.0", "25.0"], ["891.0", "25.0"], ["915.0", "27.0"], ["869.0", "23.0"], ["883.0", "27.0"], ["902.0", "23.0"], ["896.0", "22.0"], ["874.0", "20.0"], ["890.0", "24.0"], ["905.0", "25.0"], ["857.0", "23.0"], ["863.0", "26.0"], ["893.0", "26.0"], ["880.0", "26.0"], ["875.0", "22.0"], ["847.0", "29.0"], ["907.0", "24.0"], ["849.0", "27.0"], ["889.0", "23.0"], ["897.0", "21.0"], ["856.0", "25.0"], ["881.0", "27.0"], ["865.0", "25.0"], ["876.0", "22.0"], ["850.0", "25.0"], ["912.0", "26.0"], ["851.0", "28.0"], ["868.0", "23.0"], ["898.0", "24.0"], ["911.0", "27.0"], ["913.0", "27.0"], ["871.0", "24.0"], ["872.0", "22.0"], ["976.0", "26.0"], ["979.0", "28.0"], ["943.0", "28.0"], ["934.0", "26.0"], ["926.0", "28.0"], ["983.0", "30.0"], ["968.0", "28.0"], ["936.0", "29.0"], ["920.0", "27.0"], ["927.0", "28.0"], ["981.0", "30.0"], ["925.0", "28.0"], ["942.0", "27.0"], ["947.0", "30.0"], ["965.0", "25.0"], ["970.0", "27.0"], ["945.0", "30.0"], ["964.0", "27.0"], ["953.0", "22.0"], ["918.0", "23.0"], ["946.0", "30.0"], ["972.0", "27.0"], ["957.0", "25.0"], ["941.0", "27.0"], ["980.0", "29.0"], ["919.0", "25.0"], ["948.0", "30.0"], ["954.0", "22.0"], ["916.0", "24.0"], ["984.0", "30.0"], ["923.0", "27.0"], ["971.0", "29.0"], ["750.0", "26.0"], ["718.0", "35.0"], ["766.0", "35.0"], ["975.0", "26.0"], ["986.0", "30.0"], ["935.0", "25.0"], ["961.0", "24.0"], ["917.0", "25.0"], ["967.0", "27.0"], ["940.0", "27.0"], ["921.0", "27.0"], ["963.0", "28.0"], ["939.0", "27.0"], ["985.0", "31.0"], ["929.0", "27.0"], ["932.0", "26.0"], ["922.0", "27.0"], ["952.0", "17.0"], ["977.0", "27.0"], ["960.0", "25.0"], ["933.0", "26.0"], ["931.0", "26.0"], ["937.0", "29.0"], ["973.0", "27.0"], ["955.0", "23.0"], ["951.0", "28.0"], ["944.0", "29.0"], ["949.0", "33.0"], ["969.0", "28.0"], ["924.0", "26.0"], ["930.0", "25.0"], ["956.0", "23.0"], ["928.0", "25.0"], ["765.0", "34.0"], ["711.0", "35.0"], ["744.0", "23.0"], ["751.0", "29.0"], ["724.0", "38.0"], ["720.0", "34.0"], ["748.0", "26.0"], ["747.0", "24.0"], ["741.0", "37.0"], ["759.0", "27.0"], ["749.0", "27.0"], ["743.0", "14.0"], ["702.0", "39.0"], ["732.0", "36.0"], ["771.0", "34.0"], ["767.0", "34.0"], ["727.0", "38.0"], ["770.0", "34.0"], ["754.0", "28.0"], ["735.0", "39.0"], ["768.0", "34.0"], ["716.0", "34.0"], ["726.0", "39.0"], ["760.0", "27.0"], ["725.0", "39.0"], ["737.0", "35.0"], ["769.0", "32.0"], ["742.0", "36.0"], ["752.0", "28.0"], ["721.0", "36.0"], ["734.0", "37.0"], ["761.0", "30.0"], ["738.0", "35.0"], ["966.0", "25.0"], ["974.0", "26.0"], ["987.0", "29.0"], ["962.0", "27.0"], ["982.0", "30.0"], ["950.0", "31.0"], ["938.0", "29.0"], ["978.0", "26.0"], ["958.0", "24.0"], ["959.0", "26.0"], ["745.0", "23.0"], ["712.0", "34.0"], ["714.0", "32.0"], ["700.0", "39.0"], ["705.0", "36.0"], ["730.0", "36.0"], ["706.0", "32.0"], ["701.0", "40.0"], ["715.0", "34.0"], ["733.0", "37.0"], ["763.0", "31.0"], ["758.0", "29.0"], ["755.0", "29.0"], ["722.0", "36.0"], ["707.0", "37.0"], ["887.0", "24.0"], ["864.0", "24.0"], ["877.0", "23.0"], ["886.0", "25.0"], ["894.0", "22.0"], ["873.0", "21.0"], ["914.0", "28.0"], ["892.0", "27.0"], ["728.0", "39.0"], ["704.0", "37.0"], ["861.0", "25.0"], ["909.0", "26.0"], ["900.0", "24.0"], ["713.0", "33.0"], ["866.0", "25.0"], ["862.0", "25.0"], ["879.0", "26.0"], ["885.0", "24.0"], ["888.0", "21.0"], ["859.0", "22.0"], ["860.0", "24.0"], ["899.0", "25.0"], ["906.0", "26.0"], ["753.0", "31.0"], ["740.0", "36.0"], ["746.0", "24.0"], ["723.0", "37.0"], ["729.0", "38.0"], ["708.0", "37.0"], ["717.0", "35.0"], ["756.0", "27.0"], ["901.0", "25.0"], ["762.0", "28.0"], ["719.0", "35.0"], ["703.0", "37.0"], ["764.0", "32.0"], ["736.0", "36.0"], ["710.0", "33.0"], ["757.0", "27.0"], ["709.0", "37.0"], ["731.0", "37.0"], ["739.0", "37.0"], ["882.0", "27.0"], ["870.0", "21.0"], ["854.0", "27.0"]]')
  
  # Load numbers in list into arrays of size 5
  for lines in grouper(5,points):
      xa = None
      ya = None
      set = False
      for line in lines:
          datax.append(line[0])
          datay.append(line[1])
          data.append([line[0],line[1]])
          if set == False:
              xa = np.array(line[0])
              ya = np.array(line[1])
              set = True
          else:
              xa = np.vstack((xa,np.array(line[0])))
              ya = np.vstack((ya,np.array(line[1])))
      train.append([xa,ya])
  
  # Network Input / Output
  inputsize = 1
  outputsize = 1
  
  a_0 = tf.placeholder(tf.float32, [None, inputsize])
  y = tf.placeholder(tf.float32, [None, outputsize])
  
  # Hidden layers
  middle = 50
  middle2 = 30
  w_1 = tf.Variable(tf.truncated_normal([inputsize, middle]))
  b_1 = tf.Variable(tf.truncated_normal([1, middle]))
  w_12 = tf.Variable(tf.truncated_normal([middle, middle2]))
  b_12 = tf.Variable(tf.truncated_normal([1, middle2]))
  w_2 = tf.Variable(tf.truncated_normal([middle2, outputsize]))
  b_2 = tf.Variable(tf.truncated_normal([1, outputsize]))
  
  def sigma1(x):
      return  tf.nn.sigmoid(x)
  
  def sigma2(x):
      return tf.nn.softplus(x)
  
  z_1 = tf.add(tf.matmul(a_0, w_1), b_1)
  a_1 = sigma1(z_1)
  z_12 = tf.add(tf.matmul(a_1, w_12), b_12)
  a_12 = sigma1(z_12)
  z_2 = tf.add(tf.matmul(a_12, w_2), b_2)
  a_2 = sigma2(z_2)
  
  
  cost = tf.nn.l2_loss((a_2 - y))
  step = tf.train.GradientDescentOptimizer(0.1).minimize(cost)
  
  sess = tf.InteractiveSession()
  sess.run(tf.initialize_all_variables())
  lasterror = -1
  times = 0
  
  # Train for 100 epoch (tried also longer, but no additional gain)
  for i in range(100):
      for tup in train:
          sess.run(step, feed_dict = {a_0: tup[0],
                                  y : tup[1]})
  
  
  # Plot the predicted outcome
  def _transpose(matrix):
      return matrix[np.newaxis, :].T
  x = np.arange(0,1400, 0.01)
  y = []
  res =  sess.run(a_2, feed_dict = {a_0: _transpose(x)})
  plt.plot(x,res)
  
  #Plot data
  plt.plot(datax,datay,"ro")
  plt.show()
  </code></pre>
  
  <p>I also tried scaling the output between 0 and 1, but this also did not help the network to converge.</p>
  
  <p>The result looks like this (datapoint, with the line being the prediction):</p>
  
  <p><a href="https://i.stack.imgur.com/22ZMr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/22ZMr.png" alt="enter image description here"></a></p>
  
  <p>I am open for any suggestions, what could help here.</p>
  
  <p>Thank you.</p>