File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change 1
1
import * as tf from '@tensorflow/tfjs-node-gpu' ;
2
2
3
3
const model = await tf . loadLayersModel ( 'file:///dev/shm/brain/model.json' ) ;
4
- model . loadWeights ( )
5
4
6
- console . log ( 'prediction' , model . predict ( tf . tensor ( [ Array ( 400 ) ] ) ) ) ;
5
+ // obscure looking tf operations taken from
6
+ // https://github.com/prouhard/tfjs-mountaincar/blob/master/src/js/model.js#L69-L74
7
+ const pred = model . predict ( tf . tensor ( [ Array ( 400 ) ] ) ) ;
8
+ const sigmoid = tf . sigmoid ( pred ) ;
9
+ const probs = tf . div ( sigmoid , tf . sum ( sigmoid ) ) ;
10
+ const end = tf . multinomial ( probs , 1 ) . dataSync ( ) [ 0 ] - 1 ;
11
+
12
+ console . log ( 'probs' , end ) ;
Original file line number Diff line number Diff line change @@ -11,5 +11,6 @@ export const createModel = (inputVectorSize) => {
11
11
12
12
// Prepare the model for training: Specify the loss and the optimizer.
13
13
model . compile ( { loss : 'meanSquaredError' , optimizer : 'sgd' } ) ;
14
+ model . summary ( ) ;
14
15
return model ;
15
16
}
You can’t perform that action at this time.
0 commit comments