conv-neural-network

When to use what type of padding for convolution layers?

谁说胖子不能爱 提交于 2019-12-23 12:30:01
问题 I know when we are using convolution layers in a neural net we usually use padding and mainly constant padding(e.g. zero padding). And there are different kinds of padding(e.g. symmetric, reflective, constant). But I am not sure what are the advantages and disadvantages of using different padding methods and when to use which one. 回答1: it really depends on the situation for what the neural network is intended. I would not tell it pros and cons. This time the world cannot put into a binary

Copying weights from one Conv2D layer to another

只愿长相守 提交于 2019-12-23 12:23:55
问题 Context I have trained a model on MNIST using Keras. My goal is to print images after the first layer with the first layer being a Conv2D layer. To go about this I'm creating a new model with a single Conv2D layer in which I'll copy the weights from the trained network into the new one. # Visualization for image ofter first convolution model_temp = Sequential() model_temp.add(Conv2D(32, (3, 3), activation='relu', input_shape=(28,28,1,))) trained_weights = model.layers[0].get_weights()[0]

Copying weights from one Conv2D layer to another

一世执手 提交于 2019-12-23 12:21:07
问题 Context I have trained a model on MNIST using Keras. My goal is to print images after the first layer with the first layer being a Conv2D layer. To go about this I'm creating a new model with a single Conv2D layer in which I'll copy the weights from the trained network into the new one. # Visualization for image ofter first convolution model_temp = Sequential() model_temp.add(Conv2D(32, (3, 3), activation='relu', input_shape=(28,28,1,))) trained_weights = model.layers[0].get_weights()[0]

Max over time pooling in Keras

浪尽此生 提交于 2019-12-23 07:47:13
问题 I'm using CNNs in Keras for an NLP task and instead of max pooling, I'm trying to achieve max over time pooling. Any ideas/hacks on how to achieve this? What I mean by max over time pooling is to pool the highest value, no matter where they are in the vector 回答1: Assuming that your data shape is (batch_size, seq_len, features) you may apply: seq_model = Reshape((seq_len * features, 1))(seq_model) seq_model = GlobalMaxPooling1D()(seq_model) 来源: https://stackoverflow.com/questions/41958115/max

Food101 SqueezeNet Caffe2 number of iterations

老子叫甜甜 提交于 2019-12-23 05:05:07
问题 I am trying to classify the ETH Food-101 dataset using squeezenet in Caffe2. My model is imported from the Model Zoo and I made two types of modifications to the model: 1) Changing the dimensions of the last layer to have 101 outputs 2) The images from the database are in NHWC form and I just flipped the dimensions of the weights to match. (I plan on changing this) The Food101 dataset has 75,000 images for training and I am currently using a batch size of 128 and a starting learning rate of

Passing Individual Channels of Tensors to Layers in Keras

烂漫一生 提交于 2019-12-23 02:18:33
问题 I am trying to emulate something equivalent to a SeparableConvolution2D layer for the theano backend (it already exists for the TensorFlow backend). As the first step What I need to do is pass ONE channel from a tensor into the next layer. So say I have a 2D convolution layer called conv1 with 16 filters which produces an output with shape: (batch_size, 16, height, width) I need to select the subtensor with shape (: , 0, : , : ) and pass it to the next layer. Simple enough right? This is my

Error when checking input: expected conv2d_1_input to have 4 dimensions, but got array with shape (800, 1000)

蹲街弑〆低调 提交于 2019-12-23 01:28:10
问题 i am trying to do sentimental analysis using CNN i my code my data has (1000,1000) shape when i pass the data to convolution2D it is throwing me an error. which i am not able to resolve. i tried below solution but still facing issue. When bulding a CNN, I am getting complaints from Keras that do not make sense to me. My code is below. TfIdf = TfidfVectorizer(max_features=1000) X = TfIdf.fit_transform(x.ravel()) Y = df.iloc[:,1:2].values X_train, X_test, Y_train, Y_test = train_test_split(X, Y

ValueError: Tensor:(…) is not an element of this graph

独自空忆成欢 提交于 2019-12-22 14:16:36
问题 I am using keras' pre-trained model and the error came up when trying to get predictions. I have the following code in flask server: from NeuralNetwork import * @app.route("/uploadMultipleImages", methods=["POST"]) def uploadMultipleImages(): uploaded_files = request.files.getlist("file[]") getPredictionfunction = preTrainedModel["VGG16"] for file in uploaded_files: path = os.path.join(STATIC_PATH, file.filename) result = getPredictionfunction(path) This is what I have in my NeuralNetwork.py

Where to apply batch normalization on standard CNNs

末鹿安然 提交于 2019-12-22 09:30:05
问题 I have the following architecture: Conv1 Relu1 Pooling1 Conv2 Relu2 Pooling3 FullyConnect1 FullyConnect2 My question is, where do I apply batch normalization? And what would be the best function to do this in TensorFlow? 回答1: The original batch-norm paper prescribes using the batch-norm before ReLU activation. But there is evidence that it's probably better to use batchnorm after the activation. Here's a comment on Keras GitHub by Francois Chollet: ... I can guarantee that recent code written

Tensorflow Error: “Cannot parse tensor from proto”

血红的双手。 提交于 2019-12-22 06:38:43
问题 I am creating a deep CNN with tensorflow. I have already created the architecture, and now I am in the process of training. When I begin to train the model, I use the command: sess.run(tf.global_variables_initializer()) When this command is called, I get the error located below. My intuition tells me that maybe the tensor shape is too large to parse/initialize. I have researched this error and there seems to be little documentation online. Does this error give enough information to tell what