tf.expand_dims】的更多相关文章

tf.expand_dims和tf.squeeze函数 一.tf.expand_dims() Function tf.expand_dims(input, axis=None, name=None, dim=None) Inserts a dimension of 1 into a tensor’s shape. 在第axis位置增加一个维度 Given a tensor input, this operation inserts a dimension of 1 at the dimensio…
主要是因为tflearn官方的例子总是有embeding层,去掉的话要conv1d正常工作,需要加上expand_dims network = input_data(shape=[None, 100], name='input') network = tf.expand_dims(network, 2) branch1 = conv_1d(network, 128, 3, padding='valid', activation='relu', regularizer="L2") ref…
1.  tf.split(3, group, input)  # 拆分函数    3 表示的是在第三个维度上, group表示拆分的次数, input 表示输入的值 import tensorflow as tf import numpy as np x = [[1, 2], [3, 4]] Y = tf.split(axis=1, num_or_size_splits=2, value=x) sess = tf.Session() for y in Y: print(sess.run(y))…
from http://blog.csdn.net/qq_31780525/article/details/72280284 tf.expand_dims() Function tf.expand_dims(input, axis=None, name=None, dim=None) Inserts a dimension of 1 into a tensor’s shape.  在第axis位置增加一个维度 Given a tensor input, this operation insert…
想要增加一维,可以使用tf.expand_dims(input, dim, name=None)函数 t = np.array(np.arange(1, 1 + 30).reshape([2, 3, 5]), dtype=np.float32) array([[[ 1., 2., 3., 4., 5.], [ 6., 7., 8., 9., 10.], [11., 12., 13., 14., 15.]], [[16., 17., 18., 19., 20.], [21., 22., 23.,…
import tensorflow as tf import tensorflow.contrib.slim as slim import rawpy import numpy as np import tensorflow as tf import struct import glob import os from PIL import Image import time __sony__ = 0 __huawei__ = 1 __blackberry__ = 2 __stage_raw2ra…
命名空间及变量共享 # coding=utf-8 import tensorflow as tf import numpy as np import matplotlib.pyplot as plt; with tf.variable_scope('V1') as scope: a1 = tf.get_variable(name='a1', shape=[1], initializer=tf.constant_initializer(1)) scope.reuse_variables() a3…
1. tf.nn.embedding_lookup(W, X) W的维度为[len(vocabulary_list), 128], X的维度为[?, 8],组合后的维度为[?, 8, 128] 代码说明一下:即根据每一行X中的一个数,从W中取出对应行的128个数据,比如X[1, 3]个数据是3062,即从W中的第3062行取出128个数据 import numpy as np import tensorflow as tf data = np.array([[2, 1], [3, 4], [5,…
1. rnn.BasicLSTMCell(num_hidden) #  构造单层的lstm网络结构 参数说明:num_hidden表示隐藏层的个数 2.tf.nn.dynamic_rnn(cell, self.x, tf.float32) # 执行lstm网络,获得state和outputs 参数说明:cell表示实例化的rnn网络,self.x表示输入层,tf.float32表示类型 3. tf.expand_dim(self.w, axis=0) 对数据增加一个维度 参数说明:self.w表…
1. tf.reduce_mean(a) : 求平均值 2. tf.truncated_normal([3,2],stddev=0.1) : 从正态分布中输出随机值,标准差为0,1,构造矩阵为3*2的 3. tf.argmax(vector, 1):返回的是vector中的最大值的索引号,如果vector是一个向量,那就返回一个值,如果是一个矩阵,那就返回一个向量,这个向量的每一个维度都是相对应矩阵行的最大值元素的索引号. A = [[1,3,4,5,6]]B = [[1,3,4], [2,4,…