File tree 4 files changed +59
-0
lines changed
4 files changed +59
-0
lines changed Original file line number Diff line number Diff line change
1
+ // 将设置放入此文件中以覆盖默认值和用户设置。
2
+ {
3
+ // whitelist numpy to remove lint errors
4
+ "python.linting.pylintArgs" : [
5
+ " --extension-pkg-whitelist=numpy"
6
+ ],
7
+ "python.linting.pylintEnabled" : false
8
+ }
Original file line number Diff line number Diff line change
1
+ #coding:utf-8
2
+ import tensorflow as tf
3
+ #import numpy as np
4
+ matrix1 = tf .constant ([[3. , 3. ]])
5
+ matrix2 = tf .constant ([[2. ],[2. ]])
6
+
7
+ product = tf .matmul (matrix1 , matrix2 )
8
+
9
+ sess = tf .Session ()
10
+
11
+ result = sess .run (product )
12
+ print (result )
13
+
14
+ sess .close ()
Original file line number Diff line number Diff line change
1
+ #coding:utf-8
2
+ import tensorflow as tf
3
+ import numpy as np
4
+
5
+ x_data = np .random .rand (100 ).astype ("float32" )
6
+ y_data = x_data * 0.1 + 0.3
7
+
8
+ W = tf .Variable (tf .random_uniform ([1 ],- 1.0 ,1.0 ))
9
+ b = tf .Variable (tf .zeros ([1 ]))
10
+ y = W * x_data + b
11
+
12
+ loss = tf .reduce_mean (tf .square (y - y_data ))
13
+ optimizer = tf .train .GradientDescentOptimizer (0.5 )
14
+ train = optimizer .minimize (loss )
15
+
16
+ init = tf .initialize_all_variables ()
17
+
18
+ sess = tf .Session ()
19
+ sess .run (init )
20
+
21
+ for step in range (201 ):
22
+ sess .run (train )
23
+ if step % 20 == 0 :
24
+ print (step ,sess .run (W ), sess .run (b ))
Original file line number Diff line number Diff line change
1
+ #coding:utf-8
2
+ import tensorflow as tf
3
+ sess = tf .InteractiveSession ()
4
+
5
+ x = tf .Variable ([1.0 , 2.0 ])
6
+ a = tf .constant ([3.0 , 3.0 ])
7
+
8
+ x .initializer .run ()
9
+
10
+ sub = tf .subtract (x , a )
11
+ print (sub .eval ())
12
+
13
+ sess .close ()
You can’t perform that action at this time.
0 commit comments