質問編集履歴

1

参考ソース追加

2019/07/07 11:27

投稿

teefpc
teefpc

スコア111

test CHANGED
File without changes
test CHANGED
@@ -15,3 +15,45 @@
15
15
  np.add.at = np.scatter_add
16
16
 
17
17
  ```
18
+
19
+
20
+
21
+
22
+
23
+
24
+
25
+ [参考「ゼロから作るdeep learning 2」](https://github.com/oreilly-japan/deep-learning-from-scratch-2/blob/master/common/np.py)
26
+
27
+
28
+
29
+ ```Python
30
+
31
+ # coding: utf-8
32
+
33
+ from common.config import GPU
34
+
35
+
36
+
37
+
38
+
39
+ if GPU:
40
+
41
+ import cupy as np
42
+
43
+ np.cuda.set_allocator(np.cuda.MemoryPool().malloc)
44
+
45
+ np.add.at = np.scatter_add
46
+
47
+
48
+
49
+ print('\033[92m' + '-' * 60 + '\033[0m')
50
+
51
+ print(' ' * 23 + '\033[92mGPU Mode (cupy)\033[0m')
52
+
53
+ print('\033[92m' + '-' * 60 + '\033[0m\n')
54
+
55
+ else:
56
+
57
+ import numpy as np
58
+
59
+ ```