numpy> Random number list output> zip () / print%

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

I was trying to create a csv file that stores random number data used in TensorFlow.

Reference http://qiita.com/7of9/items/b56708f38fa14f944d76#comment-59b925b947211bb8abcf

prep_data.py


import numpy as np
import random

numdata=10
x_data = np.random.rand(numdata)
y_data = np.sin(2*np.pi*x_data) + 0.3 * np.random.rand()

for xs, ys in zip(x_data, y_data):
	print '%.5f, %.5f' % (xs, ys)

result


$ python prep_data.py 
0.55805, -0.09681
0.09217, 0.80718
0.03410, 0.47250
0.20549, 1.22104
0.98297, 0.15306
0.03321, 0.46702
0.83019, -0.61584
0.74709, -0.73994
0.92803, -0.17704
0.93578, -0.13275

Recommended Posts

numpy> Random number list output> zip () / print%
Random number generation summary by Numpy
list and numpy
I made a random number graph with Numpy
Ruby number output 0 padding
[Note] Random number creation?
Output unicode string list
Numpy Useful method list