Skip to content

Commit

Permalink
A quick fix
Browse files Browse the repository at this point in the history
A quick fix
  • Loading branch information
suquark committed Mar 19, 2017
1 parent 20a2119 commit 6a300ef
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
25 changes: 18 additions & 7 deletions backend/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import { prod } from 'util/array.js';
* This class provides a more uniform and general way to store and save images with same shape
*/
class ImageBuffer {
constructor() {}
constructor() {
this._tensor = undefined;
}

/**
* @param { Array } tsArray - Array of Tensor
Expand All @@ -31,15 +33,24 @@ class ImageBuffer {
}

get tensor() {
let image = this.images;
let t = new Tensor(this.shape);
let N = t.size;
for (let i = 0; i < N; i++) {
t.w[i] = (image[i] / 255.0) * 2.0 - 1.0;
if (!this._tensor) {
let image = this.images;
let t = new Tensor(this.shape);
let N = t.size;
for (let i = 0; i < N; i++) {
t.w[i] = (image[i] / 255.0) * 2.0 - 1.0;
}
this._tensor = t;
}
return t;
return this._tensor;
}

get tensors() {

}



/**
* Load images from buffer
* @param { object } t - Object that contains info about tensor we want to get
Expand Down
2 changes: 1 addition & 1 deletion dataset/mnist2000.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"name":"mnist/","nodes":[{"name":"x","shape":[28,28,1],"count":2000,"type":"images"},{"type":"Int32Array","name":"y","length":2000}]}]
[{ "name": "mnist/", "nodes": [{ "name": "x", "shape": [2000, 28, 28, 1], "type": "images" }, { "type": "Int32Array", "name": "y", "length": 2000 }] }]
10 changes: 5 additions & 5 deletions demo/dataset/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
<script src="../../transpiler/system.js"></script>
<script src="../sysconf.js"></script>

<script src="../../visualize/jquery.min.js"></script>
<script src="../../foreign/jquery.min.js"></script>
<script src="../../visualize/preload-mask.js"></script>

<link rel="stylesheet" href="../../visualize/materialize/css/materialize.min.css" />
<link rel="stylesheet" href="../../visualize/materialize/css/material_icons.css" />
<script src="../../visualize/materialize/js/materialize.min.js"></script>
<link rel="stylesheet" href="../../foreign/materialize/css/materialize.min.css" />
<link rel="stylesheet" href="../../foreign/materialize/css/material_icons.css" />
<script src="../../foreign/materialize/js/materialize.min.js"></script>


<script src="../../visualize/d3.min.js"></script>
<script src="../../foreign/d3.min.js"></script>
</head>

<body>
Expand Down

0 comments on commit 6a300ef

Please sign in to comment.