<jupyter_start><jupyter_text>Tensorflow 상수 선언<jupyter_code>import tensorflow as tf<jupyter_output><empty_output><jupyter_text>상수 선언 함수<jupyter_code>a = tf.constant([2,2], name='a')
b = tf.constant([[0,1],[2,3]],name='b')
x = tf.multiply(a,b,name='mul')
with tf.Session() as sess:
    print(sess.run(x))<jupyter_output>[[0 2]
 [4 6]]<jupyter_text>초기값 주기  0  tf.zeros(shape, dtype=tf.float32, name=None) tf.zeros_like(input_tensor, dtype=None, name=None, optimize=True)<jupyter_code># zero fill
tf.zeros([2,3], tf.int32) # ==> [[0,0,0],[0,0,0]]
input_tensor = tf.constant([[0,1],[2,3],[4,5]], name='input_tensor')
tf.zeros_like(input_tensor) #==> [[0,0],[0,0],[0,0]]<jupyter_output><empty_output><jupyter_text>1 tf.ones(shape, dtype=tf.float32, name=None) tf.one_like(input_tensor, dtype=None, name=None, optimize=True)<jupyter_code># 1 fill
tf.ones([2,3], tf.int32) # ==> [[1,1,1],[1,1,1]]
input_tensor2 = tf.constant([[0,1],[2,3],[4,5]], name='input_tensor2')
tf.zeros_like(input_tensor2) #==> [[1,1],[1,1],[1,1]]<jupyter_output><empty_output><jupyter_text>fill with specific value tf.fill(dims, value, name=None)<jupyter_code>tf.fill([2,3], 8) #==> [[8,8,8],[8,8,8]]<jupyter_output><empty_output><jupyter_text>tf.lin_space(start, stop, num, name=None)<jupyter_code>#tf.lin_space(start, stop, num, name=None)
# start -> stop
lin_space = tf.linspace(start=10.0,stop=13.0, num=4, name='lin_spae') # ==> [10. 11. 12. 13.]
with tf.Session() as sess:
    print(sess.run(lin_space))
lin_space = tf.linspace(start=11.0,stop=13.0, num=4, name='lin_spae') # ==> [10. 11. 12. 13.]
fill = tf.fill([2,3], 8, name='fill') 
with tf.Session() as sess:
    print(sess.run([lin_space, fill]))
print("test")<jupyter_output>[array([11.      , 11.666667, 12.333333, 13.      ], dtype=float32), array([[8, 8, 8],
       [8, 8, 8]], dtype=int32)]<jupyter_text>tf.range(start, limit=None, delta=1, dtype=None, name=None)<jupyter_code>range = tf.range(0,10,2, name='range')
with tf.Session() as sess:
    print(sess.run([range]))
#for _ in tf.range(4): # TypeError<jupyter_output><empty_output><jupyter_text>Random  tf.random_normal tf.truncated_normal tf.random_uniform tf.random_shuffle tf.random_crop tf.multinomial tf.random_gamma  before random do tf.set_random_seed(seed)<jupyter_code>rand = tf.random_normal([2,2], mean=0.0, stddev=1.0, dtype=tf.float32, seed=41, name = 'rand')
with tf.Session() as sess:
    print(sess.run([rand]))<jupyter_output>[array([[-1.3524637 ,  0.26046416],
       [ 1.57836   , -0.34923676]], dtype=float32)]
{'fraction_non_alphanumeric': 0.21516474791583962, 'fraction_numerical': 0.07383882493052799, 'mean_word_length': 7.0, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 38, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '562958', 'license': 'Apache-2.0', 'n_tokens_mistral': 1187, 'n_tokens_neox': 1111, 'n_words': 159, 'path': '02.tf.basic/tf.constants.ipynb', 'repo_name': 'jaeho-kang/modu-tensorflow-v2', 'size': '2519'}