Operating environment
GeForce GTX 1070 (8GB)
ASRock Z170M Pro4S [Intel Z170chipset]
Ubuntu 14.04 LTS desktop amd64
TensorFlow v0.11
cuDNN v5.1 for Linux
CUDA v8.0
Python 2.7.6
IPython 5.1.0 -- An enhanced Interactive Python.
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
GNU bash, version 4.3.8(1)-release (x86_64-pc-linux-gnu)
v0.1
test_python_170409a.py
import numpy as np
alist = [1, 2, 3, 4, 5, 6, 7, 8, 9]
xs = np.array([])
ys = np.array([])
zs = np.array([])
for idx, elem in enumerate(alist):
print('%d:%s' % (idx, elem))
if idx % 3 == 0:
xs = np.append(xs, elem)
elif idx % 3 == 1:
ys = np.append(ys, elem)
else:
zs = np.append(zs, elem)
print(xs)
print(ys)
print(zs)
Run
$ python test_python_170409a.py
0:1
1:2
2:3
3:4
4:5
5:6
6:7
7:8
8:9
[ 1. 4. 7.]
[ 2. 5. 8.]
[ 3. 6. 9.]
It served its purpose, but there may be a simpler way.
@ shiracamus's Comment taught me a simple method using slices.
Thank you for the information.
@ tuki0918's Comment taught me how to use reshape () and matrix transpose.
Thank you for the information.
Recommended Posts