I have a CNN trained on a classification task (Network is simple, 2 convolution + pooling layers and 2x fully connected layers). I would like to use this to reconstruct an image if I input a classification label.
Is this possible to achieve?
Is it possible to share weights between corresponding layers in the 2 networks?
You should have a look to cGAN implementation and why not DeepDream from Google ;)
The answer is yes it is possible, however it's not straight forward
Related
Is it possible to combine multiple types of data through a neural network and in return output a particular datatype?
For example, can I input an image and some metadata about that image, then the algorithm will output a number.
I'm thinking along the lines of stitching a CNN and ANN together.
Thanks in advance!
Yes, that is possible. Actually, that is pretty straightforward.
Commonly, what happens in image classification (for example) is that a so-called feature map (generated by the last convolutional layer in this case) gets flattened. This flattened tensor is then fed through a feed-forward Neural Network (NN) to perform the classification task.
The easiest would be to simply add one layer to your network which concatenates two tensors a and b, where a is the flattened output of the last convolutional layer and b is your meta-data (which is then ideally also a flattened tensor).
Afterwards, you simply feed the concatenated tensor (containing both the encoding of your image and the meta-data) through the feed-forward NN to perform the final classification (or generation of whatever the desired output is).
I try to switch from pytorch to tensorflow and since the model now seems to be a fixed thing in tensorflow, i stumble upon a problem when working with Convolutional Neural Networks.
I have a very simple model, just one Conv1D layer and a kernel with size 2.
I want to train it on a small Configuration, say 16 input size and then export the training results on a 32 input size.
How can i access the 3 parameters in this network? (2 kernel, 1 bias) I want to do so to apply them for the higher size case. I struggle because i need to pre-define a input size of the model, this was not the case with pytorch.
Thanks for answering, I've only found outdated answers to this question
model.layers[0].get_weights() yields the weights of the first layer, assuming model is a tf.keras.Model object.
I am working on a problem which requires me to build a deep learning model that based on certain input image it has to output another image. It is worth noting that these two images are conceptually related but they don't have the same dimensions.
At first I thought that a classical CNN with a final dense layer whose argument is the multiplication of the height and width of the output image would suit this case, but when training it was giving strange figures such as accuracy of 0.
While looking for some answers on the Internet I discovered the concepts of CNN autoencoders and I was wondering if this approach could help me solve my problem. Among all the examples I saw, the input and output of an autoencoder had the same size and dimensions.
At this point I wanted to ask if there was a type of CNN autoencoders that produce an output image that has different dimension compared to input image.
Auto-encoder (AE) is an architecture that tries to encode your image into a lower-dimensional representation by learning to reconstruct the data from such representation simultaniously. Therefore AE rely on a unsupervised (don't need labels) data that is used both as an input and as the target (used in the loss).
You can try using a U-net based architecture for your usecase. A U-net would forward intermediate data representations to later layers of the network which should assist with faster learning/mapping of the inputs into a new domain..
You can also experiment with a simple architecture containing a few ResNet blocks without any downsampling layers, which might or might not be enough for your use-case.
If you want to dig a little deeper you can look into Disco-GAN and related methods.They explicitly try to map image into a new domain while maintaining image information.
so I am using a convolutional layer as the first layer of a neural network for deep reinforcement learning to get the spatial features out of a simulation I built. The simulation gives different maps that are of different lengths and heights to process. If I understand convolutional networks, this should not matter since the channel size is kept constant. In between the convolutional network and the fully connected layers there is a spatial pyramid pooling layer so that the varying image sizes does not matter. Also the spatial data is pretty sparse. Usually it is able to go through a few states and sometimes a few episodes before the first convolutional layer spits out all Nans. Even when I fix the map size this happens. I do not know where the problem lies, where can the problem lie?
Try to initialize your weights with random numbers between 0 and 1 and then try different learning rates for your network training. (I suggest test it with learning rates equal to 10, 1, 0.1, 0.01, ...)
I have trained a Neural Network using a Matlab Neural Network Toolbox, particularly using the command nntool. The detection is basically for traffic sign and I have used a database of 90 traffic images(no-entry,no right and stop signs), each of 30 images of size 8*8 pixels of which no-entry signs are taken positive. My input is 64*90 and target as 1*90. Now, I need to use this neural network in Python for real-time recognition. What parameters do I need? I am completely new to neural networking.Here's the link to an image Here's my link to the weights
First you need to take the weights of your neural network.
An example:
[x,t] = simplefit_dataset;
net = feedforwardnet(20);
net = train(net,x,t);
wb = getwb(net)
Then I also suggest that you read on ANN structure, this will help you understand how the output of a neural network is calculated, given the weights. Then you can adapt it to your own needs and using that calculate an output in Python.