max-pooling

Custom max_pool layer: ValueError: The channel dimension of the inputs should be defined. Found `None`

a 夏天 提交于 2021-01-29 17:26:50
问题 I am working on tensorflow2 and I am trying to implement Max unpool with indices to implement SegNet. When I run it I get the following problem. I am defining the def MaxUnpool2D and then calling it in the model. I suppose that the problem is given by the fact that updates and mask have got shape (None, H,W,ch). def MaxUnpooling2D(updates, mask): size = 2 mask = tf.cast(mask, 'int32') input_shape = tf.shape(updates, out_type='int32') # calculation new shape output_shape = ( input_shape[0],

What is the difference between MaxPool and MaxPooling layers in Keras?

让人想犯罪 __ 提交于 2020-08-07 07:56:38
问题 I just started working with Keras and noticed that there are two layers with very similar names for max pooling: MaxPool and MaxPooling . I was surprised that I couldn't find the difference between these two on Google; so I am wondering what the difference is between the two if any. 回答1: they are the same. you can test it by your own import numpy as np import tensorflow as tf from tensorflow.keras.layers import * # create dummy data X = np.random.uniform(0,1, (32,5,3)).astype(np.float32)

What is the difference between MaxPool and MaxPooling layers in Keras?

余生长醉 提交于 2020-08-07 07:56:19
问题 I just started working with Keras and noticed that there are two layers with very similar names for max pooling: MaxPool and MaxPooling . I was surprised that I couldn't find the difference between these two on Google; so I am wondering what the difference is between the two if any. 回答1: they are the same. you can test it by your own import numpy as np import tensorflow as tf from tensorflow.keras.layers import * # create dummy data X = np.random.uniform(0,1, (32,5,3)).astype(np.float32)

Issues Training CNN with Prime number input dimensions

三世轮回 提交于 2019-12-24 06:07:51
问题 I am currently developing a CNN model with Keras (an autoencoder). This type my inputs are of shape (47,47,3) , that is a 47x47 image with 3 (RGB) layers. I have worked with some CNN's in the past, but this time my input dimensions are prime numbers (47 pixels). This I think is causing issues with my implementation, specifically when using MaxPooling2D and UpSampling2D in my model. I noticed that some dimensions are lost when max pooling and then up sampling . Using model.summary() I can see

Is it possible to extend “im2col” and “col2im” to N-D images?

孤街浪徒 提交于 2019-12-11 18:48:28
问题 "Im2col" has already been implemented, Implement MATLAB's im2col 'sliding' in Python, efficiently for 2-D images in Python. I was wondering whether it is possible to extend this to arbitrary N-D images? Many applications involve high-dimensional data (e.g. convolutions, filtering, max pooling, etc.). 回答1: So the purpose of this question was really just to post my solution to this problem publicly. I could not seem to find such a solution on Google, so I decided to take a stab at it myself.

NumPy Array Reshaped but how to change axis for pooling?

感情迁移 提交于 2019-12-11 07:58:55
问题 I have a 8x8 matrix as follows: [[ 0.3 0.3 0.3 0.3 0.3 0.5 0.1 -0.1] [ 0.1 0.1 -0.1 0.3 0.3 -0.1 -0.1 -0.5] [-0.1 0.1 0.3 -0.1 0.3 -0.1 -0.1 -0.1] [-0.1 0.1 0.5 0.3 -0.3 -0.1 -0.3 -0.1] [ 0.5 0.1 -0.1 0.1 -0.1 -0.1 -0.3 -0.5] [ 0.1 -0.1 -0.3 -0.5 -0.5 -0.1 -0.1 -0.3] [-0.5 -0.3 -0.3 -0.3 -0.1 -0.5 -0.1 -0.3] [-0.3 -0.3 -0.3 -0.3 -0.1 -0.1 -0.5 -0.3]] My window is 2x2. What I am trying to do is get four numbers together (up and down numbers) for pooling. Sample output looks like this: [[0.3 0

Pytorch maxpooling over channels dimension

情到浓时终转凉″ 提交于 2019-12-08 11:33:38
问题 I was trying to build a cnn to with Pytorch, and had difficulty in maxpooling. I have taken the cs231n held by Stanford. As I recalled, maxpooling can be used as a dimensional deduction step, for example, I have this (1, 20, height, width) input ot max_pool2d (assuming my batch_size is 1). And if I use (1, 1) kernel, I want to get output like this: (1, 1, height, width), which means the kernel should be slide over the channel dimension. However, after checking the pytorch docs, it says the

Pooling vs Pooling-over-time

。_饼干妹妹 提交于 2019-12-05 23:27:50
问题 I understand conceptually what is happening in a max/sum pool as a CNN layer operation, but I see this term "max pool over time", or "sum pool over time" thrown around (e.g., "Convolutional Neural Networks for Sentence Classification" paper by Yoon Kim). What is the difference? 回答1: The max-over-time pooling is usually applied in NLP (unlike ordinary max-pool, which is common in CNNs for computer vision tasks), so the setup is a little bit different. The input to the max-over-time pooling is

how to perform max/mean pooling on a 2d array using numpy

[亡魂溺海] 提交于 2019-11-27 15:37:52
问题 Given a 2D(M x N) matrix, and a 2D Kernel(K x L), how do i return a matrix that is the result of max or mean pooling using the given kernel over the image? I'd like to use numpy if possible. Note: M, N, K, L can be both even or odd and they need not be perfectly divisible by each other, eg: 7x5 matrix and 2x2 kernel. eg of max pooling: matrix: array([[ 20, 200, -5, 23], [ -13, 134, 119, 100], [ 120, 32, 49, 25], [-120, 12, 09, 23]]) kernel: 2 x 2 soln: array([[ 200, 119], [ 120, 49]]) 回答1: