Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c07cbd6
commit ecb3617
Showing
20 changed files
with
4,542 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source /etc/profile | ||
source ~/.bash_profile | ||
source ~/Coding/python_venv/LSTM/bin/activate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,95 @@ | ||
# LSTMVis | ||
Visualization Toolbox for Long Short Term Memory networks (LSTMs) | ||
|
||
![Alt text](client/assets/example1.png) | ||
|
||
|
||
## Getting started | ||
|
||
Install python requirements in your virtual environment: | ||
|
||
``` | ||
pip install -r requirements.txt | ||
``` | ||
|
||
Install bower requirements: | ||
|
||
``` | ||
cd client; bower install; cd .. | ||
``` | ||
|
||
start server: | ||
|
||
``` | ||
python server.py -dir <datadir> | ||
``` | ||
|
||
open browser at [http://localhost:8888](http://localhost:8888) | ||
|
||
|
||
## Data Directory | ||
LSTMVis parses all subdirectories of `<datadir>` for config files `lstm.yml`. | ||
A typical `<datadir>` might look like this: | ||
|
||
``` | ||
<datadir> | ||
├── parens <--- minimal example | ||
│ ├── lstm.yml | ||
│ ├── states.h5 | ||
│ ├── train.h5 | ||
│ └── words.dict | ||
├── ptb_word <-- with search functionality and meta data (part-of-speech,..) | ||
│ ├── embeddings.h5 | ||
│ ├── indexdir | ||
│ │ └── ... | ||
│ ├── lstm.yml | ||
│ ├── pos.dict | ||
│ ├── pos.h5 | ||
│ ├── states.h5 | ||
│ ├── train.h5 | ||
│ ├── weight.h5 | ||
│ └── words.dict | ||
``` | ||
|
||
|
||
|
||
a simple example of `lstm.yml` is: | ||
|
||
```yaml | ||
name: rls - ep 10 # project name | ||
|
||
files: # assign files to reference name | ||
states: rls_200_ep10_states.h5 # HDF5 files have to end with .h5 !!! | ||
train: rls.h5 | ||
words: rls.dict # dict files have to end in .dict !! | ||
|
||
# OPTIONAL: If you have information about word embedding | ||
# word_embedding: | ||
# file: embed | ||
# path: weights | ||
|
||
word_sequence: # defines the word sequence | ||
file: train # HDF5 file | ||
path: words # path to table within HDF5 | ||
dict_file: words # dictionary to map IDs from HDF5 to words | ||
|
||
states: | ||
file: states # HDF5 files containing the state for each position | ||
types: [ | ||
{type: state, layer: 1, path: states1}, # type={state, output}, layer=[1..x], path = HDF5 path | ||
{type: output, layer: 1, path: output1}, | ||
{type: state, layer: 2, path: states2}, | ||
{type: output, layer: 2, path: output2} | ||
] | ||
|
||
``` | ||
|
||
## Generate Data | ||
|
||
TODO ... | ||
|
||
## Credits | ||
|
||
LSTMVis is a project of Hendrik Strobelt, Alexander 'Sasha' Rush, Sebastian Gehrmann, and Bernd Huber at Harvard SEAS. |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "LSTMVisClient", | ||
"version": "0.1.0", | ||
"authors": [ | ||
"LSTM Team" | ||
], | ||
"description": "", | ||
"main": "", | ||
"moduleType": [], | ||
"license": "GPL", | ||
"homepage": "", | ||
"private": true, | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"test", | ||
"tests" | ||
], | ||
"dependencies": { | ||
"jquery": "~2.2", | ||
"d3": "~3.5", | ||
"lodash": "~4.6", | ||
"bootswatch": "v3.3.6+1", | ||
"font-awesome": "fontawesome#~4.5.0", | ||
"lodash.math": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>LSTM Vis</title> | ||
<script src="bower_components/jquery/dist/jquery.min.js"></script> | ||
<script src="bower_components/d3/d3.min.js"></script> | ||
<script src="bower_components/lodash/dist/lodash.min.js"></script> | ||
<script src="bower_components/bootstrap/dist/js/bootstrap.min.js"></script> | ||
|
||
<link rel="stylesheet" type="text/css" href="bower_components/bootswatch/cosmo/bootstrap.min.css"> | ||
<link rel="stylesheet" type="text/css" href="bower_components/font-awesome/css/font-awesome.min.css"> | ||
|
||
</head> | ||
<body> | ||
<div class="container"> | ||
<!--<div class="row">--> | ||
<h1 class="text-center "><img src="assets/logo.png" height="40"> - Visualization for LSTMs</h1> | ||
<!--</div>--> | ||
<!--<h2>Datasets:</h2>--> | ||
<!--<ul class="list-group" id="ds_list">--> | ||
<!--</ul>--> | ||
<div id="ds_list"></div> | ||
|
||
|
||
</div> | ||
|
||
<script> | ||
var url = ''; | ||
var query = url + '/api/info/'; | ||
$.ajax(query, { | ||
dataType: 'json', | ||
success: function (info) { | ||
console.log(info); | ||
|
||
d3.text('assets/schema_interactive.svg', function (e_, schema_svg) { | ||
|
||
// console.log(schema_svg); | ||
|
||
|
||
var lis = d3.select('#ds_list').selectAll('div').data(info) | ||
.enter().append('div') | ||
.attr({ | ||
class: "row" | ||
}); | ||
|
||
lis.append('h3').text(function (d, i) {return d.info.name}); | ||
lis.append('hr'); | ||
|
||
function add_info(parent, title, accesor) { | ||
parent.append('div').attr({ | ||
class: 'col-md-2 col-xs-3 text-right' | ||
}).style({ | ||
'font-weight': 'bold' | ||
}).html(title); | ||
|
||
parent.append('div').attr({ | ||
class: 'col-md-10 col-xs-9 text-left' | ||
}).html(function (d) {return accesor(d)}); | ||
|
||
} | ||
|
||
add_info(lis, 'file', function (d, i) {return d.project}); | ||
add_info(lis, 'meta', function (d, i) { | ||
var keys = Object.keys(d.info.meta); | ||
return (keys.length > 0) ? keys.join(', ') : '---' | ||
}); | ||
add_info(lis, 'embedding_size', function (d, i) {return d.info.word_embedding.size.join(' x ')}); | ||
add_info(lis, 'sequence_length', function (d, i) {return d.info.word_sequence.size[0]}); | ||
|
||
|
||
lis.each(function (ds, ds_id) { | ||
var that = d3.select(this); | ||
ds.info.states.types.forEach(function (d, i) { | ||
|
||
add_info(that, d.file + ':' + d.path, function () { | ||
return '<a href="pattern_finder.html?data_set=' + ds_id + '&source=' + d.file + '::' + d.path + '">' | ||
+ 'layer ' + d.layer + ' ' + d.type | ||
+ ' ( size: ' + d.size.join(' x ') + ')' | ||
+ (d.unsigned ? ' - <b>unsigned</b>' : '') | ||
+ '</a>' | ||
}) | ||
}); | ||
|
||
// var no_layers = d3.max(ds.info.states.types.map(function (d, i) {return d.layer})) + 1; | ||
// var all_data_subsets = ds.info.states.types.map(function (d, i) {return d.layer + d.type}); | ||
// var all_subset_paths = ds.info.states.types.map(function (d, i) {return d.path}); | ||
// | ||
// var svgs = that.append('p').attr({class: 'text-center'}); | ||
// | ||
// _.range(1, no_layers).forEach(function (layer_x) { | ||
// | ||
// var span = svgs.append('p').html(schema_svg); | ||
// span.select('.picto_states').attr({ | ||
// hidden: function () { | ||
// return _.includes(all_data_subsets, layer_x + 'state') ? null : true; | ||
// } | ||
// }).on('click', function (d) { | ||
// var i = _.indexOf(all_data_subsets, layer_x + 'state'); | ||
// window.open('pattern_finder.html?data_set='+ds_id+'&source='+all_subset_paths[i]) | ||
// console.log(ds_id, layer_x, all_subset_paths[i]); | ||
// }); | ||
// span.select('.picto_output').attr({ | ||
// hidden: function () { | ||
// return _.includes(all_data_subsets, layer_x + 'output') ? null : true; | ||
// } | ||
// }).on('click', function (d) { | ||
// var i = _.indexOf(all_data_subsets, layer_x + 'output'); | ||
// window.open('pattern_finder.html?data_set='+ds_id+'&source='+all_subset_paths[i]) | ||
// | ||
// | ||
// console.log(ds_id, layer_x, all_subset_paths[i]); | ||
// }); | ||
// | ||
// }) | ||
|
||
|
||
}); | ||
|
||
}) | ||
|
||
|
||
//<div class="panel panel-success"> | ||
// <div class="panel-heading"> | ||
// <h3 class="panel-title">Panel success</h3> | ||
// </div> | ||
// <div class="panel-body"> | ||
// Panel content | ||
// </div> | ||
//</div> | ||
|
||
// info.forEach(function(ds){ | ||
// | ||
// | ||
// | ||
// }) | ||
|
||
|
||
} | ||
}) | ||
|
||
|
||
</script> | ||
|
||
|
||
</body> | ||
</html> |
Oops, something went wrong.