In [6]:
import tensorflow as tf
import numpy as np

In [2]:
import csv

In [3]:
file = open('test.csv')

print(file)


<_io.TextIOWrapper name='test.csv' mode='r' encoding='UTF-8'>

In [4]:
reader = csv.reader(file)

In [5]:
for row in reader:
    print(row)


['1', '2', '3', '4']

In [8]:
tensor_1d = np.array([1.3,1,4.0,23.99])

In [9]:
print(tensor_1d)


[  1.3    1.     4.    23.99]

In [10]:
tensor_1d.ndim


Out[10]:
1

In [11]:
tensor_1d.shape


Out[11]:
(4,)

In [12]:
tensor_1d.dtype


Out[12]:
dtype('float64')

In [13]:
tf_tensor = tf.convert_to_tensor(tensor_1d,dtype=tf.float64)

In [14]:
print(tf_tensor)


Tensor("Const:0", shape=(4,), dtype=float64)

In [15]:
sess = tf.Session()

In [16]:
sess.close()

In [19]:
#with구분을 사용하면 Session의 close() 호출을 자동으로 해준다.
with tf.Session() as sess:
    print(sess.run(tf_tensor))
    print(sess.run(tf_tensor[0]))
    print(sess.run(tf_tensor[2]))


[  1.3    1.     4.    23.99]
1.3
4.0

In [ ]: