标签:add odi author ESS code ted result and mon
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 27 11:16:32 2018
@author: myhaspl
"""
# TensorFlow and tf.keras
import tensorflow as tf
a = tf.constant([[1, 2], [3, 4]])
b = tf.constant([[5, 0], [0, 6]])
c=tf.ones([2,2],tf.int32)
result1=tf.accumulate_n([a, b])
result2=tf.accumulate_n([a, b,c])
result3=tf.accumulate_n([a, b, c], shape=[2, 2], tensor_dtype=tf.int32)
sess=tf.Session()
with sess:
print sess.run(result1)
print sess.run(result2)
print sess.run(result3)
[[ 6 ?2]
?[ 3 10]]
[[ 7 ?3]
?[ 4 11]]
[[ 7 ?3]
?[ 4 11]]
import tensorflow as tf
a = tf.constant([[1., 2.], [3., 4.]])
b = a*2-4
c= (b-1)*2
res=tf.add_n([a,b,c])
sess=tf.Session()
with sess:
print sess.run(res)
[[-7. ?0.]
?[ 7. 14.]]
tensorflow-累加accumulate_n,add_n
标签:add odi author ESS code ted result and mon
原文地址:http://blog.51cto.com/13959448/2327981