-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtsne_robot.js
69 lines (54 loc) · 2.05 KB
/
tsne_robot.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* global labels */
var convnetjs = require('./scripts/convnet-min');
// make network from file
var net = new convnetjs.Net();
// make layers
var layer_defs = [];
layer_defs.push({type:'input', out_sx:1, out_sy:1, out_depth:76});
layer_defs.push({type:'fc', num_neurons:250, activation:'relu'});
layer_defs.push({type:'fc', num_neurons:250, activation:'relu'});
layer_defs.push({type:'fc', num_neurons:250, activation:'relu'});
var output_type = 'regression'
if (output_type == 'softmax') {
layer_defs.push({type:'softmax', num_classes:2});
}
else {
layer_defs.push({type:'regression', num_neurons:20});
}
net.makeLayers(layer_defs);
// forward prop the data
// FORMAT for tsne:
// vectors of values
//
// for neural networks, that means activations for the list of inputs
//
// input 1, neuron 1, neuron 2, neuron 3 ... neuron n
// input 2, neuron 1, neuron 2, neuron 3 ... neuron n
// input 3, neuron 1, neuron 2, neuron 3 ... neuron n
// TSNE stuff
// initialize data. Here we have 3 points and some example pairwise dissimilarities
//var from_file = require('./matlab/simple_mnist.json'); //tsne data from matlab
var helperjs = require('./helper.js');
var helper = new helperjs.helper();
var from_file = require('./robot/humanoid_points.json'); //tsne data from python
var points = from_file.points
console.log("Points: "+points.length);
console.log(points[points.length-20]);
// NORMALIZE the tsne outputs
console.log("Normalizing by layers");
links = helper.normalizeBetweenLayers(net, points, 0, 8);
console.log("LINK LENGTH: "+links.length);
n_points = helper.normalizeByLayers(net, points, 0, 8);
var net_opt ={'name':'humanoid',
'node_scale':1,
'link_scale':4,
'link_opcty':32,
'nodeWidth':40,
'nodePadding':0};
var collapse_input = -1;
var slim_thresh = 0.98;
net_opt.name = 'walker';
helper.dataToSankey(net, n_points, links, net_opt, 'data/humanoid.json', collapse_input, slim_thresh);
//var slim_thresh = 0.98;
//net_opt.name = 'runner';
//helper.dataToSankey(net, n_points, links, net_opt, 'data/biped_all.json', collapse_input, slim_thresh);