neural-network

Caffe SigmoidCrossEntropyLoss Layer Loss Function

余生长醉 提交于 2020-01-13 09:40:07
问题 I was looking through the code of Caffe's SigmoidCrossEntropyLoss layer and the docs and I'm a bit confused. The docs list the loss function as the logit loss (I'd replicate it here, but without Latex, the formula would be difficult to read. Check out the docs link, it's at the very top). However, the code itself ( Forward_cpu(...) ) shows a different formula Dtype loss = 0; for (int i = 0; i < count; ++i) { loss -= input_data[i] * (target[i] - (input_data[i] >= 0)) - log(1 + exp(input_data[i

Bag of features and Neural Networks in Matlab

ε祈祈猫儿з 提交于 2020-01-13 03:24:12
问题 I've been trying to implement a neural network in Matlab that is capable of recognizing images based on their features. I am attempting to use the Bag of features/words approach to obtain a discrete vector of features that I can then feed into my neural network. I have been using this example as a guide - http://in.mathworks.com/help/vision/examples/image-category-classification-using-bag-of-features.html One line in the code (featureVector = encode(bag, img);) counts the word occurrences in

reduce size of pretrained deep learning model for feature generation

喜夏-厌秋 提交于 2020-01-13 02:43:18
问题 I am using an pretrained model in Keras to generate features for a set of images: model = InceptionV3(weights='imagenet', include_top=False) train_data = model.predict(data).reshape(data.shape[0],-1) However, I have a lot of images and the Imagenet model outputs 131072 features (columns) for each image. With 200k images I would get an array of (200000, 131072) which is too large to fit into memory. More importantly, I need to save this array to disk and it would take 100 GB of space when

reduce size of pretrained deep learning model for feature generation

南笙酒味 提交于 2020-01-13 02:41:08
问题 I am using an pretrained model in Keras to generate features for a set of images: model = InceptionV3(weights='imagenet', include_top=False) train_data = model.predict(data).reshape(data.shape[0],-1) However, I have a lot of images and the Imagenet model outputs 131072 features (columns) for each image. With 200k images I would get an array of (200000, 131072) which is too large to fit into memory. More importantly, I need to save this array to disk and it would take 100 GB of space when

slice/split a layer in keras as in caffe

妖精的绣舞 提交于 2020-01-13 02:13:15
问题 I have used this converter to convert a Caffe model to Keras. But one of my layers is of type slice and it needs to be converted as well but the converter currently does not support this and raises an exception. Is there any work around for it? Here is my layer: layer { name: "slice_label" type: SLICE bottom: "label" top: "label_wpqr" top: "label_xyz" slice_param { slice_dim: 1 slice_point: 4 } } 回答1: It seems that you want to use a Lambda layer. In this case you may do the following: sliced

Performing Convolution (NOT cross-correlation) in pytorch

不羁的心 提交于 2020-01-12 18:43:30
问题 I have a network (https://github.com/TheAbhiKumar/tensorflow-value-iteration-networks) that I am trying to implement in pytorch (I'm very new to pytorch, however, not at all new to machine learning). In short, I cannot seem to figure out how to implement "pure" convolution in pytorch. In tensorflow it could be accomplished like this: def conv2d_flipkernel(x, k, name=None): return tf.nn.conv2d(x, flipkernel(k), name=name, strides=(1, 1, 1, 1), padding='SAME') With the flipkernel function being

How to get gradient values using keras.backend.gradients()

点点圈 提交于 2020-01-12 09:35:13
问题 I am trying to get derivative of output of a Keras model with respect to the input (x) of the model (not the weights). It seems like the easiest way is to use "gradients" from keras.backend which returns a tensor of gradients (https://keras.io/backend/). I am new with tensorflow and not comfortable with it yet. I have got the gradient tensor, and trying to get numerical values for it for different values of input (x). But it seems like the gradient value is independent of the input x (which

Multinomial classification using neuralnet package

我的梦境 提交于 2020-01-12 08:43:32
问题 This question ought to be real simple. But the documentation isn't helping. I am using R. I must use the neuralnet package for a multinomial classification problem. All examples are for binomial or linear output. I could do some one-vs-all implementation using binomial output. But I believe I should be able to do this by having 3 units as the output layer, where each is a binomial (ie. probability of that being the correct output). No? This is what I would using nnet (which I believe is doing

Keras - Fusion of a Dense Layer with a Convolution2D Layer

浪尽此生 提交于 2020-01-12 08:26:35
问题 I want to make a custom layer which is supposed to fuse the output of a Dense Layer with a Convolution2D Layer. The Idea came from this paper and here's the network: the fusion layer tries to fuse the Convolution2D tensor ( 256x28x28 ) with the Dense tensor ( 256 ). here's the equation for it: y_global => Dense layer output with shape 256 y_mid => Convolution2D layer output with shape 256x28x28 Here's the description of the paper about the Fusion process: I ended up making a new custom layer

Keras - Fusion of a Dense Layer with a Convolution2D Layer

只愿长相守 提交于 2020-01-12 08:26:31
问题 I want to make a custom layer which is supposed to fuse the output of a Dense Layer with a Convolution2D Layer. The Idea came from this paper and here's the network: the fusion layer tries to fuse the Convolution2D tensor ( 256x28x28 ) with the Dense tensor ( 256 ). here's the equation for it: y_global => Dense layer output with shape 256 y_mid => Convolution2D layer output with shape 256x28x28 Here's the description of the paper about the Fusion process: I ended up making a new custom layer