LoginSignup
1
3

More than 5 years have passed since last update.

numpy > csvファイルを読み込んで、 1列目と2列目の値をinput1,outputとして取得 > input1 = data[:,0] / output = data[:,1]

Last updated at Posted at 2016-11-12
動作環境
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

以下のようなファイルがある。

input.csv
0.74597, -0.91122
0.33339, 0.95432
0.03281, 0.29314
0.49378, 0.12754
0.59515, -0.47443
0.19094, 1.02040
0.04446, 0.36420
0.02983, 0.27479
0.72129, -0.89531
0.97207, -0.08616
0.54730, -0.20436
0.47366, 0.25323
0.58349, -0.41239
0.42188, 0.55983
...

上記のファイルを読むには以下のようにするようだ。
参考 http://www.mwsoft.jp/programming/numpy/csv.html
参考 http://stackoverflow.com/questions/11739796/turn-2d-numpy-array-into-1d-array-for-plotting-a-histogram

import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm

data = np.loadtxt('input.csv', delimiter=',')
input1 = data[:,0]
output = data[:,1]
>> input1
array([ 0.74597,  0.33339,  0.03281,  0.49378,  0.59515,  0.19094,
        0.04446,  0.02983,  0.72129,  0.97207,  0.5473 ,  0.47366,
        0.58349,  0.42188,  0.4674 ,  0.78199,  0.36685,  0.3272 ,
        0.08699,  0.50938,  0.30515,  0.29046,  0.1528 ,  0.6754 ,
        0.493  ,  0.87203,  0.50209,  0.47111,  0.6476 ,  0.07248,
        0.68567,  0.45286,  0.31038,  0.65485,  0.22235,  0.99213,
        0.80919,  0.2719 ,  0.48896,  0.50926,  0.30707,  0.05993,
        0.10803,  0.13582,  0.34657,  0.69719,  0.34416,  0.017  ,
        0.69265,  0.49431,  0.17915,  0.85606,  0.84609,  0.14715,
        0.86554,  0.60495,  0.60713,  0.02405,  0.05717,  0.49937,
        0.24258,  0.68672,  0.11015,  0.50363,  0.88794,  0.11778,
        0.93471,  0.33972,  0.04038,  0.79928,  0.5235 ,  0.52673,
        0.31692,  0.78884,  0.25574,  0.69226,  0.57933,  0.96118,
        0.5842 ,  0.07607,  0.82006,  0.1139 ,  0.84374,  0.43982,
        0.63605,  0.58926,  0.15797,  0.38462,  0.69245,  0.14642,
        0.71501,  0.43495,  0.31003,  0.62805,  0.44885,  0.60561,
        0.07738,  0.62272,  0.31518,  0.5267 ])
In [22]:
>> output
array([-0.91122,  0.95432,  0.29314,  0.12754, -0.47443,  1.0204 ,
        0.3642 ,  0.27479, -0.89531, -0.08616, -0.20436,  0.25323,
       -0.41239,  0.55983,  0.29185, -0.89141,  0.83086,  0.97311,
        0.60824,  0.02958,  1.02903,  1.05633,  0.90771, -0.80368,
        0.13243, -0.63173,  0.07535,  0.26899, -0.71161,  0.52828,
       -0.83096,  0.38033,  1.01737, -0.73807,  1.07341,  0.03901,
       -0.84318,  1.07901,  0.15776,  0.0303 ,  1.02486,  0.45619,
        0.71632,  0.84196,  0.90996, -0.85699,  0.91849,  0.19506,
       -0.84732,  0.12419,  0.99101, -0.69759, -0.73475,  0.88684,
       -0.6594 , -0.52421, -0.53495,  0.23899,  0.44   ,  0.09242,
        1.08738, -0.83353,  0.72663,  0.06563, -0.55887,  0.76276,
       -0.31034,  0.93374,  0.33948, -0.86399, -0.05864, -0.07869,
        1.00135, -0.88191,  1.08781, -0.84645, -0.38959, -0.15306,
       -0.41627,  0.54842, -0.81622,  0.74458, -0.74305,  0.45762,
       -0.66599, -0.44341,  0.92587,  0.75158, -0.84686,  0.88407,
       -0.88747,  0.4859 ,  1.01817, -0.63208,  0.40437, -0.52746,
        0.55574, -0.60844,  1.00576, -0.07853])
1
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
3