tensorflow笔记9:nn_ops.bias_add 函数
完整代码引入:from tensorflow.python.ops import nn_ops
tensorflow version:1.9
代码演示:
import os import tensorflow as tf import numpy as np import sys from tensorflow.python.ops import nn_ops #array_ops.concat([inputs, state], 1) a = tf.constant([[1,12,8,6], [3,4,6,7]]) # shape [2,4] m = tf.constant([1,12,8,6]) # shape [4] he = nn_ops.bias_add(a,m) with tf.Session() as sess: print (he) print (he.eval())
输出:
Tensor("BiasAdd:0", shape=(2, 4), dtype=int32) [[ 2 24 16 12] [ 4 16 14 13]]