In [65]:
import tensorflow as tf
import numpy as np
In [2]:
a = tf.constant(2)
b = tf.constant(3)
c = a + b
In [3]:
print(c)
In [5]:
with tf.Session() as sess:
print(sess.run(c))
In [56]:
a = tf.placeholder(shape=(), dtype = tf.int32)
In [57]:
b = tf.placeholder(shape=(),dtype = tf.int32)
In [58]:
c = tf.add(a, b)
In [59]:
print(c)
In [60]:
with tf.Session() as sess:
print(sess.run(c, feed_dict={a:3, b:4}))
In [61]:
a = tf.placeholder(shape=(2,), dtype=tf.int32)
b = tf.placeholder(shape=(2,), dtype=tf.int32)
c = a + b
In [62]:
with tf.Session() as sess:
print(sess.run(c, feed_dict={a:[1,1], b:[2,2]}))
In [63]:
a = tf.placeholder(shape=(2,2), dtype=tf.int32)
b = tf.placeholder(shape=(2,2), dtype=tf.int32)
c = a+b
In [64]:
with tf.Session() as sess:
print(sess.run(c, feed_dict={a: [[1,1],[1,1]], b: [[2,2],[2,2]]}))
In [73]:
a = np.array([1,2,3])
In [74]:
a.shape
Out[74]:
In [75]:
b = np.array([[1,1],[2,2]])
In [76]:
b.shape
Out[76]:
In [77]:
c = np.array(3)
In [78]:
c.shape
Out[78]:
In [82]:
c # 스칼라(0차원 텐서)
Out[82]:
In [83]:
a #벡터 (1차원 텐서)
Out[83]:
In [84]:
b #행렬 (2차원 텐서)
Out[84]:
In [87]:
d = np.array([[[1,2],[2,3]],[[3,4],[2,3]]])
In [88]:
d.shape #3차원 텐서
Out[88]:
In [89]:
d
Out[89]:
In [90]:
a = np.array([[1,1],[1,1]])
In [91]:
b = np.array([[2,2],[2,2]])
In [92]:
a.shape
Out[92]:
In [93]:
a
Out[93]:
In [94]:
b
Out[94]:
In [95]:
c=a+b
In [96]:
c
Out[96]:
In [97]:
a = np.array([3,3])
In [98]:
a
Out[98]:
In [99]:
c = np.dot(a,b)
In [100]:
c
Out[100]:
In [ ]: