How To Determine the ‘filter’ Parameter in the Keras Conv2D Function

Actually – there is no a good answer to your question. Most of the architectures are usually carefully designed and finetuned during many experiments. I could share with you some of the rules of thumbs one should apply when designing its own architecture: Avoid a dimension collapse in the first layer. Let’s assume that your … Read more

Altering trained images to train neural network

It is a very good way to increase the number of date you have. What you’ll do depends on your data. For example, if you are training on data obtained from a sensor, you may want to add some noise to the training data so that you can increase your dataset. After all, you can … Read more

“RuntimeError: Expected 4-dimensional input for 4-dimensional weight 32 3 3, but got 3-dimensional input of size [3, 224, 224] instead”?

As Usman Ali wrote in his comment, pytorch (and most other DL toolboxes) expects a batch of images as an input. Thus you need to call output = model(data[None, …]) Inserting a singleton “batch” dimension to your input data. Please also note that the model you are using might expect a different input size (3x229x229) … Read more

How to load only specific weights on Keras

If your first 9 layers are consistently named between your original trained model and the new model, then you can use model.load_weights() with by_name=True. This will update weights only in the layers of your new model that have an identically named layer found in the original trained model. The name of the layer can be … Read more

How to turn off dropout for testing in Tensorflow?

The easiest way is to change the keep_prob parameter using a placeholder_with_default: prob = tf.placeholder_with_default(1.0, shape=()) layer = tf.nn.dropout(layer, prob) in this way when you train you can set the parameter like this: sess.run(train_step, feed_dict={prob: 0.5}) and when you evaluate the default value of 1.0 is used.

Finding gradient of a Caffe conv-filter with regards to input

Caffe net juggles two “streams” of numbers. The first is the data “stream”: images and labels pushed through the net. As these inputs progress through the net they are converted into high-level representation and eventually into class probabilities vectors (in classification tasks). The second “stream” holds the parameters of the different layers, the weights of … Read more

Visualizing output of convolutional layer in tensorflow

I don’t know of a helper function but if you want to see all the filters you can pack them into one image with some fancy uses of tf.transpose. So if you have a tensor that’s images x ix x iy x channels >>> V = tf.Variable() >>> print V.get_shape() TensorShape([Dimension(-1), Dimension(256), Dimension(256), Dimension(32)]) So … Read more

Max pool layer vs Convolution with stride performance

Yes that can be done. Its explained in the paper ‘Striving for simplicity: The all convolutional net’ https://arxiv.org/pdf/1412.6806.pdf. Quote from the paper: ‘We find that max-pooling can simply be replaced by a convolutional layer with increased stride without loss in accuracy on several image recognition benchmarks’