Repository: deeplearning4j/deeplearning4j
Issue: UIServer: plotVocab and TsneModule routes do not match up

For some reason the route that would accept a POST request has been replaced with a GET based route.

https://github.com/deeplearning4j/deeplearning4j/blob/master/deeplearning4j-ui-parent/deeplearning4j-play/src/main/java/org/deeplearning4j/ui/module/tsne/TsneModule.java#L50
```java
//        Route r5 = new Route("/tsne/post/:sid", HttpMethod.POST, FunctionType.Function, this::postFile);
        Route r5 = new Route("/tsne/post/:sid", HttpMethod.GET, FunctionType.Function, this::postFile);
```

However, the InMemoryLookupTable.plotVocab method still tries to use the POST based version:
https://github.com/deeplearning4j/deeplearning4j/blob/master/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/embeddings/inmemory/InMemoryLookupTable.java#L222

```java
String address = connectionInfo.getFirstPart() + "/tsne/post/" + connectionInfo.getSessionId();
 //            System.out.println("ADDRESS: " + address);
URI uri = new URI(address);

HttpURLConnection connection = (HttpURLConnection) uri.toURL().openConnection();
connection.setRequestMethod("POST");
```


@fenneclabs found the Bug, and it has shown itself with the following exception:
```
15:54:23.369 Trc [main ] BarnesHutTsne <> Error at iteration 99 is -176691.3168704078
RESPONSE CODE: 404
15:54:23.416 Std [main ] InMemoryLookupTable <> Error posting to remote UI at http://localhost:9000/tsne/post/08cd2dcb-f68a-4861-abd6-76ce86d186aa java.io.FileNotFoundException: http://localhost:9000/tsne/post/08cd2dcb-f68a-4861-abd6-76ce86d186aa
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at sun.net.www.protocol.http.HttpURLConnection$10.run(HttpURLConnection.java:1926)
```

The bug affects both 0.9.1 and current master.

In Order to reproduce the bug, simply add the following to Word2VecRawTextExample after the `vec.fit()` call:
```
  BarnesHutTsne tsne = new BarnesHutTsne.Builder()
            .setMaxIter(1)
            .theta(0.5)
            .normalize(false)
            .learningRate(500)
            .useAdaGrad(false)
            .build();
        UIServer uiServer = UIServer.getInstance();
        StatsStorage statsStorage = new InMemoryStatsStorage();          
        uiServer.attach(statsStorage);

        vec.lookupTable().plotVocab(tsne, 42, new UiConnectionInfo.Builder()
            .setPort(uiServer.getPort())
            .build());
```

Changed files:
deeplearning4j-ui-parent/deeplearning4j-play/src/main/java/org/deeplearning4j/ui/module/tsne/TsneModule.java
deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/embeddings/inmemory/InMemoryLookupTable.java

diff --git a/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/embeddings/inmemory/InMemoryLookupTable.java b/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/embeddings/inmemory/InMemoryLookupTable.java
index 3961c9416e..3d483ad391 100644
--- a/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/embeddings/inmemory/InMemoryLookupTable.java
+++ b/deeplearning4j-nlp-parent/deeplearning4j-nlp/src/main/java/org/deeplearning4j/models/embeddings/inmemory/InMemoryLookupTable.java
@@ -222,13 +222,25 @@ public class InMemoryLookupTable<T extends SequenceElement> implements WeightLoo
             connection.setRequestMethod("POST");
             connection.setRequestProperty("User-Agent", "Mozilla/5.0");
             //            connection.setRequestProperty("Content-Type", "application/json");
-            connection.setRequestProperty("Content-Type", "multipart/form-data");
+            connection.setRequestProperty("Content-Type", "multipart/form-data; boundary=-----TSNE-POST-DATA-----");
             connection.setDoOutput(true);
 
-            DataOutputStream dos = new DataOutputStream(connection.getOutputStream());
+            final OutputStream outputStream = connection.getOutputStream();
+            final PrintWriter writer = new PrintWriter(outputStream);
+            writer.println("-------TSNE-POST-DATA-----");
+            writer.println("Content-Disposition: form-data; name=\\"fileupload\\"; filename=\\"tsne.csv\\"");
+            writer.println("Content-Type: text/plain; charset=UTF-16");
+            writer.println("Content-Transfer-Encoding: binary");
+            writer.println();
+            writer.flush();
+
+            DataOutputStream dos = new DataOutputStream(outputStream);
             dos.writeBytes(sb.toString());
             dos.flush();
+            writer.println();
+            writer.flush();
             dos.close();
+            outputStream.close();
 
             try {
                 int responseCode = connection.getResponseCode();
diff --git a/deeplearning4j-ui-parent/deeplearning4j-play/src/main/java/org/deeplearning4j/ui/module/tsne/TsneModule.java b/deeplearning4j-ui-parent/deeplearning4j-play/src/main/java/org/deeplearning4j/ui/module/tsne/TsneModule.java
index 131e48d459..e903206603 100644
--- a/deeplearning4j-ui-parent/deeplearning4j-play/src/main/java/org/deeplearning4j/ui/module/tsne/TsneModule.java
+++ b/deeplearning4j-ui-parent/deeplearning4j-play/src/main/java/org/deeplearning4j/ui/module/tsne/TsneModule.java
@@ -47,8 +47,7 @@ public class TsneModule implements UIModule {
         Route r2 = new Route("/tsne/sessions", HttpMethod.GET, FunctionType.Supplier, this::listSessions);
         Route r3 = new Route("/tsne/coords/:sid", HttpMethod.GET, FunctionType.Function, this::getCoords);
         Route r4 = new Route("/tsne/upload", HttpMethod.POST, FunctionType.Supplier, this::uploadFile);
-        //        Route r5 = new Route("/tsne/post/:sid", HttpMethod.POST, FunctionType.Function, this::postFile);
-        Route r5 = new Route("/tsne/post/:sid", HttpMethod.GET, FunctionType.Function, this::postFile);
+        Route r5 = new Route("/tsne/post/:sid", HttpMethod.POST, FunctionType.Function, this::postFile);
         return Arrays.asList(r1, r2, r3, r4, r5);
     }
 
@@ -126,7 +125,8 @@ public class TsneModule implements UIModule {
 
         List<String> lines;
         try {
-            lines = FileUtils.readLines(file);
+            // Set to uploadedFileLines as well, as the TSNE UI doesn't allow to properly select Sessions yet
+            lines = uploadedFileLines = FileUtils.readLines(file);
         } catch (IOException e) {
             //            System.out.println("**** COULD NOT READ FILE ****");
             return badRequest("Could not read from uploaded file");