tensor

ValueError: Features are incompatible with given information. Given features: Tensor(“input:0”, shape=(?, 198), dtype=float32)

匿名 (未验证) 提交于 2019-12-03 01:19:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Hi I am trying to implement GMM using tensorflow. But I am getting the following error :- ValueError: Features are incompatible with given information. Given features: Tensor("input:0", shape=(?, 198), dtype=float32), required signatures: TensorSignature(dtype=tf.float64, shape=TensorShape([Dimension(None), Dimension(198)]), is_sparse=False). Following is my code:- from tensorflow.contrib.factorization.python.ops import gmm as gmm_lib import numpy as np num_clusters = 200 x = np.array([[random.random() for i in range(198)] for j in range

TypeError: Value passed to parameter 'input' has DataType float64 not in list of allowed values: float16, bfloat16, float32

匿名 (未验证) 提交于 2019-12-03 00:59:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have read many questions similar to mine, but all of them are different with mine. for itr in xrange(MAX_ITERATION): train_images, train_annotations = train_dataset_reader.next_batch(batch_size) # train_images=tf.image.convert_image_dtype(train_images,np.float32) # train_annotations=tf.image.convert_image_dtype(train_annotations,np.float32) # print(train_images_.get_shape(),train_annotations_.get_shape()) # train_images=tf.cast(train_images,tf.float32) # train_images = tf.to_float(train_images) # train_annotations = tf.to_float(train

convert python ndarray to theano tensor type variable

匿名 (未验证) 提交于 2019-12-03 00:58:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have ndarray like : diag = [] diag.append(np.diag([1,1,0])) diag.append(np.diag([0,1,1])) diag [array([[1, 0, 0], [0, 1, 0], [0, 0, 0]]), array([[0, 0, 0], [0, 1, 0], [0, 0, 1]])] How can I convert it into Theano tensor variable of type float 64, matrix ? As I need to perform dot operation like Theano.dot(diag, X) where X is shared variable of type float 64, matrix. 回答1: Just create a SharedVariable like this diag_ = theano.shared(np.array(diag).astype("float64")) theano.dot(diag_, X) http://deeplearning.net/software/theano/library/compile

'tensorboard' is not recognized as an internal or external command,

匆匆过客 提交于 2019-12-03 00:49:25
Just started using Tensorflow, but I am not able to use tensorboard command on my cmd, it gives the error command C:\Users\tushar\PycharmProjects>tensorboard --logdir="NewTF" 'tensorboard' is not recognized as an internal or external command, operable program or batch file. I am using window 10 and have installed tensorboard library/ I had the same problem for tensorflow 1.5.0 and windows10. Following tensor documentation ("Launching TensorBoard" section) , you can try: python -m tensorboard.main --logdir=[PATH_TO_LOGDIR] Now tensorboard is working properly for me. I also had the same sort of

tenforflow controlflow 2---the implementation of control flow

匿名 (未验证) 提交于 2019-12-03 00:43:02
! 如何判断计算哪个分支?如何判断循环的结束?如何把循环分割成计算子图?tf是如何实现控制流的呢?这不禁引起了我的好奇。 TensorFlow: Large-Scale Machine Learning on Heterogeneous Distributed Systems ,2 TensorFlow: A system for large-scale machine learning ,3 Implementation of Control Flow in TensorFlow 和4 Dynamic Control Flow in Large-Scale Machine Learning ,博客里的表述很多都是翻译的原文,也包含了一些我阅读源码后的理解,我姑且把这篇归为翻译。起初开始看tensorflow源代码,走了不少弯路,不知从何看起。看完这些论文再去研究源代码,才有些登堂入室的感觉。对tensorflow 计算图感兴趣的同学,可以研究一下。 Switch : 取决于输入p的值,Switch 算子把 d 的值传给两个输出中的某一个 。两个输入都可用,Switch节点才可执行 Merge : A Merge 算子把一个可用的输入传给输出。只要任意一个输入可用,Merge便可执行。 Enter Exit NextIteration : NextIteration 算子 把输入d

tensorflow编程模式的理解

匿名 (未验证) 提交于 2019-12-03 00:42:01
1.MNIST数据库下载好后,在tensorflow/examples/tutorials/mnist/下建立文件夹MNIST_data即可运行本程序 2.关键在与理解Operation,Tensor,Graph,只有执行session.run()时操作才真正执行 import tensorflow.examples.tutorials.mnist.input_data as input_data mnist = input_data.read_data_sets(‘MNIST_data/‘,one_hot = True) import tensorflow as tf # 定义计算图 # 操作Operation为图的节点(如下面的tf.placeholder(tf.float32,[None,784])等) # 数据Tensor为图的边(如下面的x,y等) # 添加Operation时不会立即执行,只有执行session.run(Operation或Tensor)时才会真正执行 x = tf.placeholder(tf.float32,[None,784]) y = tf.placeholder(tf.float32,[None,10]) W = tf.Variable(tf.zeros([784,10]),tf.float32) b = tf.Variable(tf

Tensorflow c++ 实践及各种坑

匿名 (未验证) 提交于 2019-12-03 00:37:01
Tensorflow c++ 实践及各种坑 在这篇文章中: Tensorflow当前官网仅包含python、C、Java、Go的发布包,并无C++ release包,并且tensorflow官网也注明了并不保证除python以外库的稳定性,在功能方面python也是最完善的。众所周知,python在开发效率、易用性上有着巨大的优势,但作为一个解释性语言,在性能方面还是存在比较大的缺陷,在各类AI服务化过程中,采用python作为模型快速构建工具,使用高级语言(如C++,java)作为服务化程序实现是大势所趋。本文重点介绍tensorflow C++服务化过程中实现方式及遇到的各种问题。 实现方案 对于tensorflow c++库的使用,有两种方法: (1) 最佳方式当然是直接用C++构建graph,但是当前c++tensorflow库并不像python api那样full-featured。可参照builds a small graph in c++ here, C++ tensorflow api中还包含cpu和gpu的数字内核实现的类,可用以添加新的op。可参照 https://www.tensorflow.org/extend/adding_an_op (2) 常用的方式,c++调用python生成好的graph。本文主要介绍该方案。 实现步骤 (1)

【Tensorflow】使用笔记

匿名 (未验证) 提交于 2019-12-03 00:32:02
tf.dynamic_rnn sequence_length :这个参数用来指定每个example的长度,比如上面的例子中,我们令 sequence_length为[20,13],表示第一个example有效长度为20,第二个example有效长度为13,当我们传入这个参数的时候,对于第二个example,TensorFlow对于13以后的padding就不计算了,其last_states将重复第13步的last_states直至第20步,而outputs中超过13步的结果将会被置零。 数据格式 :一维np array,int类型 Tensor的axis参数 比如一个tensor的维度为[1,2,3],则axis的取值:0对应1那个维度,1对应2那个维度,2对应3那个维度。 tf.multiply tf.multiply(a,b),这个函数实现元素级别的相乘,也就是两个相乘的数元素各自相乘,不是矩阵乘法,注意和tf.matmul区别。 tf.nn.sigmoid_cross_entropy_with_logits 这个损失函数适用于多标签任务,分类之间不排斥。 输入 logits: 一个Tensor。数据类型是以下之一:float32或者float64。 targets: 一个Tensor。数据类型和数据维度都和 logits 相同。 name: 为这个操作取个名字。 输出 一个

TensorFlow导入数据(tf.data)

匿名 (未验证) 提交于 2019-12-03 00:30:01
上一篇 介绍了TensorFlow读取数据的四种方法:tf.data、Feeding、QueueRunner、Preloaded data。 本篇的内容主要介绍 tf.data API的使用 Ŀ¼ 基于 tf.data API,我们可以使用简单的代码来构建复杂的输入 pipeline。 (例1,从分布式文件系统中读取数据、进行预处理、合成为 batch、训练中使用数据集;例2,文本模型的输入 pipeline 需要从原始文本数据中提取符号、根据对照表将其转换为嵌入标识符,以及将不同长度的序列组合成batch数据等。) 使用 tf.data API 可以轻松处理大量数据、不同的数据格式以及复杂的转换。 tf.data API 在 TensorFlow 中引入了 两个新概念 : tf.data.Dataset :表示一系列元素,其中每个元素包含一个或多个 Tensor 对象。例如,在图片管道中,一个元素可能是单个训练样本,具有一对表示图片数据和标签的张量。可以通过两种不同的方式来创建数据集。 1 直接从 Tensor 创建 Dataset (例如 Dataset.from_tensor_slices() );当然 Numpy 也是可以的,TensorFlow 会自动将其转换为 Tensor。 2 通过对一个或多个 tf.data.Dataset 对象来使用变换(例如 Dataset

tf.summary.scalar

匿名 (未验证) 提交于 2019-12-03 00:29:01
Tensorflow(r1.4)API--tf.summary.scalar 2017年12月18日 09:55:01 阅读数:601 scalar(name,tensor,collections=None,family=None) 函数参数 name :生成节点的名字,也会作为TensorBoard中的系列的名字。 tensor :包含一个值的实数Tensor。 collection :图的集合键值的可选列表。新的求和op被添加到这个集合中。缺省为 [GraphKeys.SUMMARIES] family :可选项;设置时用作求和标签名称的前缀,这影响着TensorBoard所显示的标签名。 函数简介 返回值 :一个字符串类型的标量张量,包含一个 Summary protobuf 返回错误 : ValueError tensor有错误的类型或shape。 函数求出的 Summary 中有一个包含输入tensor的Tensor.proto 文章来源: tf.summary.scalar