iT邦幫忙

第 12 屆 iThome 鐵人賽

DAY 22
1
AI & Data

AI的介紹-水果系列 第 22

Day 22 深度學習實作

  • 分享至 

  • twitterImage
  •  

大家好~~歡迎來到第二十二篇 深度學習實作

本篇將會介紹 Tensorflow 的內部相關方法。

a = 1
b = 2
c = 3

ab = a + b
bc = b * c

if ab == 3:
    print("正確")
import tensorflow as tf

a = tf.constant(1)
b = tf.constant(2)
c = tf.constant(3)
d = tf.constant(4)
add1 = tf.add(a, b)
mul1 = tf.multiply(b, c)
add2 = tf.add(c, d)
output = tf.add(add1, mul1)

with tf.Session() as sess:
    print sess.run(output)

上一次有跟大家介紹 Tensorflow 的概念,那麼上次的程式有講到 Tensorflow 的程式架構非常特別,他不像基礎的程式碼那麼單純,為什麼呢,他需要 tf.constant 來宣告,或者 tf.運算方法來進行數學計算,最後輸出執行必須要透過,tf.Session 來做最後的結尾,才能讓整體的程式達到完整。

起初碰到這個語法的時候也會感到很奇怪,為何要加上那麼多程序才可以輸出,但是大家可以想像一下, Tensorflow 其實就很像一個系統架構,他所輸入的資料就是對他輸入系統相關資料,它會形成一個系統巨大的輸出架構,就像上一篇所顯示的圖形輸出的樣子,所以大家可以把他撰寫的方式想的簡單一點就跟一般宣告差不多的方式。

那麼 tf 介紹就到這裡為止,下一篇會以其他方向繼續介紹

想簡單一些,許多的問題就會變得很單純。


上一篇
Day 21 深度學習實作
下一篇
Day 23 深度學習實作
系列文
AI的介紹-水果30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言