tensorflow-eagerAPI
生活随笔
收集整理的這篇文章主要介紹了
tensorflow-eagerAPI
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
tensorflow-eagerAPI
調用該API可以不通過 tensorflow.Session.run()調用 定義的張量constant tensor,可以直接print
# -*- coding: utf-8 -*- from __future__ import absolute_import, division, print_function import numpy as np import tensorflow as tf import tensorflow.contrib.eager as tfe# 設置 eager API tfe.enable_eager_execution()a = tf.constant(2) b = tf.constant(3) print('a = %i' % a) print('b = %i' % b) # run op no tf.Session.run() print("can run op without tf.Session.run")c = a + b c1 = a * b print("no Session... c=%i" % c) print("no Session... c1=%i" % c1)# eagerAPI完全兼容numpy # 定義張量 define constant tensors a = tf.constant([[2., 1.],[1., 0]], dtype=tf.float32) # tensor b = tf.constant([[3., 0.],[5., 1.]], dtype=tf.float32) c2 = tf.matmul(a, b) # 矩陣相乘matmulprint("tensor:\n a=%s" % a) print("tensor:\n b=%s" % b) print("tensor multply :\n c2=%s" % c2)print(a.shape[0]) # 多少組維度信息 print(a.shape[1]) # 維度# tensor對象能夠迭代? range ????? for i in range(a.shape[0]):for u in range(a.shape[1]):print(a[i][u])?
posted on 2018-06-04 11:04 .Tang 閱讀(...) 評論(...) 編輯 收藏轉載于:https://www.cnblogs.com/tangpg/p/9132304.html
總結
以上是生活随笔為你收集整理的tensorflow-eagerAPI的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 译:9.使用Redis进行消息传递
- 下一篇: jquery 初步学习