tensor

tensorflow error - you must feed a value for placeholder tensor 'in'

可紊 提交于 2019-12-11 14:14:10
问题 I'm trying to implement queues for my tensorflow prediction but get the following error - you must feed a value for placeholder tensor 'in' with dtype float and shape [1024,1024,3] The program works fine if I use the feed_dict, Trying to replace feed_dict with queues. The program basically takes a list of positions and passes the image np array to the input tensor. for each in positions: y,x = each images = img[y:y+1024,x:x+1024,:] a = images.astype('float32') q = tf.FIFOQueue(capacity=200

How to set input with image for tensorflow-lite in c++?

浪子不回头ぞ 提交于 2019-12-11 12:44:46
问题 I am trying to move our Tensoflow model from Python+Keras version to Tensorflow Lite with C++ on an embedded platform. It looks like I don't know how set properly input for interpreter. Input shape should be (1, 224, 224, 3). As an input I am taking image with openCV, converting this to CV_BGR2RGB. std::unique_ptr<tflite::FlatBufferModel> model_stage1 = tflite::FlatBufferModel::BuildFromFile("model1.tflite"); TFLITE_MINIMAL_CHECK(model_stage1 != nullptr); // Build the interpreter tflite::ops:

TensorFlow(二)卷积神经网络

China☆狼群 提交于 2019-12-11 11:55:51
TensorFlow卷积神经网络 1、反向传播 几个人站成一排第一个人看一幅画(输入数据),描述给第二个人(隐层)……依此类推,到最后一个人(输出)的时候,画出来的画肯定不能看了(误差较大)。 反向传播就是,把画拿给最后一个人看(求取误差),然后最后一个人就会告诉前面的人下次描述时需要注意哪里(权值修正) 2、什么是卷积 1.已有运算:加减乘除,幂运算指数运算 卷积:卷积是一种运算 2.卷积运算 卷积操作是使用一个二维的卷积核在一个批处理的图片上进行不断扫描。具体操作是将一个卷积核在每张图片上按照一个合适的尺寸在每个通道上面进行扫描 3.卷积过程 如下图所示,用一个3 3的卷积核在5 5的图像上做卷积的过程 4.在三通道图像上的卷积过程 如下: 5.卷积函数 3、卷积函数 tf.nn.conv2d 参数一:input input就是需要做卷积的图像(这里要求用Tensor来表示输入图像,并且Tensor(一个4维的Tensor,要求类型为float32)的shape为[batch, in_height, in_width, in_channels]具体含义[训练时一个batch图像的数量,图像高度,图像宽度, 图像通道数]) 参数二:filter filter就是卷积核(这里要求用Tensor来表示卷积核,并且Tensor(一个4维的Tensor,要求类型与input相同

How to implement tensor product for arbitrary order tensors in octave?

南楼画角 提交于 2019-12-11 07:09:10
问题 I dont have access to matlab, so I am trying some things with octave . How would you efficiently implement the tensor product described in the following formula? My approach for arbitrary order tensors a and b is the following % Tensor product function out = tp(a,b) if isvector(a) da = prod(size(a)); else da = size(a); endif if isvector(b) db = prod(size(b)); else db = size(b); endif out = reshape(a(:)*(b(:)'),[da,db]); endfunction The if statements are only there in order to catch the case

Calculating Multivariate regression using TensorFlow

杀马特。学长 韩版系。学妹 提交于 2019-12-11 07:06:01
问题 I am trying to implement a Multivariate regression in tensorflow where I have 192 examples with 6 features and one output variable. From my model I get a matrix (192, 6) while it should be (192, 1). Does anybody know what is wrong with my code? I provided my code below. # Parameters learning_rate = 0.0001 training_epochs = 50 display_step = 5 train_X = Data_ABX3[0:192, 0:6] train_Y = Data_ABX3[0:192, [24]] # placeholders for a tensor that will be always fed. X = tf.placeholder('float', shape

How to create a vector from a constant in tensorflow

南楼画角 提交于 2019-12-11 06:05:50
问题 How is it that you would create a tensorflow vector from a tensorflow constant/variable etc? For example I have a constant x and I want to create a vector which is [x] . I have tried the code below and it doesn't work. Any help would be appreciated. x = tf.placeholder_with_default(1.0,[], name="x") nextdd = tf.constant([x], shape=[1], dtype=tf.float32) 回答1: From you description, it looks like you want to use tf.expand_dims: # 't' is a tensor of shape [2] tf.shape(tf.expand_dims(t, 0)) # [1, 2

how do I change the shape of a tensor with shape 64x4x4x3 to another shape as the same as input to the network?

女生的网名这么多〃 提交于 2019-12-11 03:18:38
问题 I am trying to implement jpeg compression as a noise layer in keras. during my implemention, I need to change the shape and I am puzzled how can I do this. so I try to explain what did I do and what do I want to do. first, in the following function, I produced all DCT coefficient of an 8x8 block that produces a filter with shape 64x8x8. each one of these 64 filters is the DCT coefficients for one pixel in final DCT transform output. def gen_filters(size_x: int, size_y: int, dct_or_idct_fun:

Concatenate Two Tensors in Pytorch

泄露秘密 提交于 2019-12-10 23:36:32
问题 RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 2. Got 32 and 71 in dimension 0 at /pytorch/aten/src/THC/generic/THCTensorMath.cu:87 I have a tensor of shape [71 32 1] . I want to make it of shape [100 32 1] by padding zero vectors. I tried by concatenating a padding vector of zeros of shape [29 32 1]. I get the error above. I try with a padding vector of zeros of shape [29 32 1] , I still get an error. How could I create the required tensor? 回答1: In order to

How to construct square of pairwise difference from a vector in tensorflow?

放肆的年华 提交于 2019-12-10 23:22:25
问题 I have a 1D vector having N dimension in TensorFlow, how to construct sum of a pairwise squared difference? Example Input Vector [1,2,3] Output 6 Computed As (1-2)^2+(1-3)^2+(2-3)^2. if I have input as an N-dim vector l, the output should be sigma_{i,j}((l_i-l_j)^2). Added question : if I have a 2d matrix and want to perform the same process for each row of the matrix, and then average the results from all the rows, how can I do it? Many thanks! 回答1: For pair-wise difference, subtract the

Unable to create a tensor using torch.Tensor

核能气质少年 提交于 2019-12-10 22:40:52
问题 i was trying to create a tensor as below. import torch t = torch.tensor(2,3) i got the following error. TypeError Traceback (most recent call last) in () ----> 1 a=torch.tensor(2,3) TypeError: tensor() takes 1 positional argument but 2 were given so, i tried the following import torch t = torch.Tensor(2,3) # No error while creating the tensor # When i print i get an error print(t) i get the following error RuntimeError Traceback (most recent call last) in () ----> 1 print(a) D:\softwares