convolution

2D convolution using openCV in C

陌路散爱 提交于 2019-12-08 09:23:46
问题 I want to implement a program which performs the 2D convolution using openCV. I'm new with openCV. my naive implementation is here: #include <stdio.h> #include <cv.h> //used for kernel unsigned short int kernel[3][3] __attribute__(( aligned(32))); // input and output image unsigned short int input[512][512] __attribute__(( aligned(32))); unsigned short int output[512][512] __attribute__((aligned(32))); int main() { //data are assigned to input and kernel matrices before. const CvArr* src =

Tensorflow gradient is always zero

时间秒杀一切 提交于 2019-12-08 08:56:09
问题 I have written a small Tensorflow program which convolves an image patch by the same convolution kernel num_unrollings times in a row, and then attempts to minimize the mean squared difference between the resulting values and a target output. However, when I run the model with num_unrollings greater than 1, the gradient of my my loss ( tf_loss ) term with respect to the convolution kernel ( tf_kernel ) is zero, so no learning occurs. Here is the smallest code (python 3) I can come up with

2d convolution in python with missing data

雨燕双飞 提交于 2019-12-08 08:52:20
问题 I know there is scipy.signal.convolve2d function to handle 2 dimension convolution for 2d numpy array, and there is numpy.ma module to handle missing data, but these two methods don't seem to compatible with each other (which means even if you mask a 2d array in numpy, the process in convolve2d won't be affected). Is there any way to handle missing values in convolution using only numpy and scipy packages? For example: 1 - 3 4 5 1 2 - 4 5 Array = 1 2 3 - 5 - 2 3 4 5 1 2 3 4 - Kernel = 1 0 0

How to Optimize this Image convolution filter Method in MonoTouch?

旧时模样 提交于 2019-12-08 07:37:37
问题 After having realized that no realtime graphics effect library exists for MonoTouch, I decided to write my own. After some research I've written a convolution method that works perfectly but, even using unsafe code, is VERY SLOW. What I'm doing wrong? Is there some optimization that I'm missing? Here is my c# class, any suggestion, not matter how small, is welcome! using System; using System.Drawing; using MonoTouch.CoreGraphics; using System.Runtime.InteropServices; using MonoTouch.UIKit;

Best approach for convolution of multiple small matrices using CUDA

ぐ巨炮叔叔 提交于 2019-12-08 06:58:49
问题 I need to preform multiple convolutions with small matrices and kernels, and I was hoping that utilizing the many processors of the GPU would enable me to it as fast as possible. The problem is as follows: I have many matrices (~1,000 to ~10,000) or relatively small sizes (~15x15 down to 1x1 - as in scalar), and a certain number of convolution masks (~20 to 1). I need to convolve all the matrices with each convolution mask example: A; %5,000 matrices of size 10x10, A(i) = a 10x10 matrix B; 10

tensorflow conv2d memory consumption explain?

六月ゝ 毕业季﹏ 提交于 2019-12-08 06:14:43
问题 output = tf.nn.conv2d(input, weights, strides = [1,3,3,1], padding = 'VALID') My input has shape 200x225x225x1, weights is 15x15x1x64. Hence, the output has shape 200x71x71x64 since (225-15)/3 + 1 = 71 Tensorboard shows that this operation consumes totally 768MB (see pic below). Assuming it takes into account the size of input (38.6MB), weights (0.06MB) and output (246.2MB) the total memory consumption should not exceed 300MB. So where does the rest of the memory consumption come from? 回答1:

3D volume processing using dask

倖福魔咒の 提交于 2019-12-08 06:13:48
问题 I’m exploring 3D interactive volume convolution with some simple stencils using dask right now. Let me explain what I mean: Assume that you have a 3D data which you would like to process through Sobel Transform (for example to get L1 or L2 gradient). Then you divide your input 3D image into subvolumes (with some overlapping boundaries – for 3x3x3 stencil Sobel it will demand +2 samples overlap/padding) Now let’s assume that you create a delayed computation of the Sobel 3D transform on entire

TensorFlow feed an integer

风格不统一 提交于 2019-12-08 05:23:11
问题 I am trying to do a convolution over variable input sizes. To achieve that, I am using a batch size of 1. However, one of the nodes is a max pooling node which needs the shape of the input as a list ksize : pooled = tf.nn.max_pool( h, ksize=[1, self.input_size - filter_size + 1, 1, 1], strides=[1, 1, 1, 1], padding='VALID', name="pool") Now, clearly the input_size can be inferred from the input (which is a placeholder): self.input_x = tf.placeholder(tf.int32, [None, None], name="input_x") But

Increasing Label Error Rate (Edit Distance) and Fluctuating Loss?

别说谁变了你拦得住时间么 提交于 2019-12-08 03:28:29
I am training a handwriting recognition model of this architecture: { "network": [ { "layer_type": "l2_normalize" }, { "layer_type": "conv2d", "num_filters": 16, "kernel_size": 5, "stride": 1, "padding": "same" }, { "layer_type": "max_pool2d", "pool_size": 2, "stride": 2, "padding": "same" }, { "layer_type": "l2_normalize" }, { "layer_type": "dropout", "keep_prob": 0.5 }, { "layer_type": "conv2d", "num_filters": 32, "kernel_size": 5, "stride": 1, "padding": "same" }, { "layer_type": "max_pool2d", "pool_size": 2, "stride": 2, "padding": "same" }, { "layer_type": "l2_normalize" }, { "layer_type"

TensorFlow feed an integer

蹲街弑〆低调 提交于 2019-12-08 03:26:26
I am trying to do a convolution over variable input sizes. To achieve that, I am using a batch size of 1. However, one of the nodes is a max pooling node which needs the shape of the input as a list ksize : pooled = tf.nn.max_pool( h, ksize=[1, self.input_size - filter_size + 1, 1, 1], strides=[1, 1, 1, 1], padding='VALID', name="pool") Now, clearly the input_size can be inferred from the input (which is a placeholder): self.input_x = tf.placeholder(tf.int32, [None, None], name="input_x") But I can't use self.input_x.get_shape()[0] because the shape is dynamic. So I intend to pass the input