@@ -2,11 +2,9 @@ const tf = require('tensorflow');
2
2
3
3
console . log ( 'Tensor Test' ) ;
4
4
5
- var tensor = tf . Tensor . create ( [ 0.5 , 42.0 ] ) ;
5
+ var tensor = tf . tensor ( [ 0.5 , 42.0 ] ) ;
6
6
console . log ( tensor . shape ) ;
7
- let data = tensor . toValue ( ) ;
8
- console . log ( data ) ;
9
- tensor . delete ( ) ;
7
+ console . log ( tensor . value ) ;
10
8
11
9
let items =
12
10
[
@@ -18,25 +16,16 @@ let items =
18
16
[ 5 , 6 ] , [ 7 , 8 ]
19
17
]
20
18
]
21
- var tensor2 = tf . Tensor . create ( items ) ;
19
+ var tensor2 = tf . tensor ( items ) ;
22
20
console . log ( tensor2 . shape ) ;
23
- let data2 = tensor2 . toValue ( ) ;
24
- console . log ( data2 ) ;
21
+ console . log ( tensor2 . value ) ;
25
22
26
23
27
24
console . log ( 'Graph Test' ) ;
28
25
29
- let graph = tf . Graph . fromGraphDef ( './graph.proto' )
30
- graph . loadOperations ( { c1 : 'c1' , c2 : 'c2' , result : 'result' } ) ;
31
- console . log ( graph ) ;
32
- graph . delete ( ) ;
33
-
26
+ let graph = tf . graph ( './graph.proto' ) ;
27
+ let session = graph . createSession ( ) ;
28
+ let result = session . run ( null , 'result' ) ;
29
+ console . log ( result ) ;
34
30
35
- console . log ( 'Session Test' ) ;
36
-
37
- let session = tf . Session . fromGraphDef ( './graph.proto' , true ) ;
38
- session . graph . loadOperations ( { result : 'result' } ) ;
39
- let tensors = session . run ( null , [ 'result' ] , null ) ;
40
- console . log ( tensors . result . toValue ( ) ) ;
41
- tensors . result . delete ( ) ;
42
- session . delete ( ) ;
31
+ graph . delete ( ) ;
0 commit comments