回答編集履歴

1

2018/10/09 12:19

投稿

tiitoi
tiitoi

スコア21956

test CHANGED
@@ -1,36 +1,36 @@
1
1
  numpy 配列の型は dtype 引数で指定しない場合は、第1引数の値で推定されます。
2
2
 
3
- 0 は int 型なので、
3
+ 0 は int 型なので、各値を 0. とするか、dtype=float と指定します。
4
4
 
5
5
 
6
6
 
7
7
  ```
8
8
 
9
+ X = np.array([[0, 0],
9
10
 
11
+ [0, 0]])
12
+
13
+ print(X.dtype) # int64
14
+
15
+ ```
16
+
17
+
18
+
19
+ ```
10
20
 
11
21
  X = np.array([[0., 0.],
12
22
 
13
23
  [0., 0.]])
14
24
 
25
+ print(X.dtype) # float64
26
+
15
27
  ```
16
-
17
-
18
-
19
- とするか、dtype=float と指定します。
20
28
 
21
29
 
22
30
 
23
31
  ```python
24
32
 
25
33
  import numpy as np
26
-
27
-
28
-
29
- X = np.array([[0, 0],
30
-
31
- [0, 0]])
32
-
33
- print(X.dtype) # int64
34
34
 
35
35
 
36
36
 
@@ -44,8 +44,6 @@
44
44
 
45
45
  X[0, 0] = 2.156789
46
46
 
47
- print(X[0, 0])
47
+ print(X[0, 0]) # 2.156789
48
-
49
-
50
48
 
51
49
  ```