I'm having trouble understanding an implementation in Keras of conditional variational autoencoders. The associated jupyter notebook is here.
My issue is, I don't see how you would pass the test set through the model. I know you need to use the recognition network for training and the prior network for testing. I think that means you're supposed to concatenate the result of the prior network and some function of the input, but I only see an encoder (which takes in both x and y) and a decoder. Where in this implementation is the prior network (just x)?
Related
I'm new to neural networks and PyTorch in particular, so please excuse my question if it turns out to be a simple one. I am creating a simple neural network that can predict the presence of lung cancer based on a given dataset.
I've reached the point where I have to create my input and output tensors with which to train my network. Unfortunately, I've run into an error while creating the tensors, and I'm not sure how to resolve it.
You need to be using vectors/matrices of numbers to create tensors. Right now you seem to be passing strings describing the data rather than the data itself.
The question is: is convolutional neural network architecture a continuous function? By convolutional I mean made of only convolutional layers. Intuitively I would say yes, since as far as I know the operation of convolution is continuous, but am I missing anything?
Also, does anybody know if this is the case also for transpose convolution?
It is a mathematical property that, if a function is differentiable, then the function is continuous; but vice versa is not true.
Now, we know that CNNs are differentiable, which is why back propagation works. Thus, they are continuous functions (in fact, every neural net which is differentiable is continuous).
I am new to ML and Pytorch and I have the following problem:
I am looking for a Fully Convolutional Network architecture in Pytorch, so that the input would be an RGB image (HxWxC or 480x640x3) and the output would be a single channel image (HxW or 480x640). In other words, I am looking for a network that will preserve the resolution of the input (HxW), and will loose the channel dimension. All of the networks that I've came across (ResNet, Densenet, ...) end with a fully connected layer (without any upsampling or deconvolution). This is problematic for two reasons:
I am restricted with the choice of the input size (HxWxC).
It has nothing to do with the output that I expect to get (a single channel image HxW).
What am I missing? Why is there even a FC layer? Why is there no up-sampling, or some deconvolution layers after feature extraction? Is there any build-in torchvision.model that might suit my requirements? Where can I find such pytorch architecture? As I said, I am new in this field so I don't really like the idea of building such a network from scratch.
Thanks.
You probably came across the networks that are used in classification. So they end up with a pooling and a fully connected layer to produce a fixed number of categorical output.
Have a look at Unet
https://lmb.informatik.uni-freiburg.de/people/ronneber/u-net/
Note: the original unet implementation use a lot of tricks.
You can simply downsample and then upsample symmetrically to do the work.
Your kind of task belongs to dense classification tasks, e.g. segmentation. In those tasks, we use fully convolution nets (see here for the original paper). In the FCNs you don't have any fully-connected layers, because when applying fully-connected layers you lose spatial information which you need for the dense prediction. Also have a look at the U-Net paper. All state-of-the art architectures use some kind of encoder-decoder architecture extended for example with a pyramid pooling module.
There are some implementations in the pytorch model zoo here. Search also Github for pytorch implementations for other networks.
Keras 2.0 removed F1 score, but I would like to monitor its value. I am using a sequential model to train a Neural Net.
I defined a function, as suggested here How to calculate F1 Macro in Keras?.
This function works fine only if used it inside model.compile. In this way I see its value at each step. The problem is that I don't want just to see its value but I would like my training to behave differently according to its value, using the callbacks of Keras.
If I try to insert my custom metric in the callbacks then I get this error:
'function object is not iterable'
Do you know how to define a function such that it can be used as an argument in the callbacks?
Callback of Keras will enable us to retrieve the model at different period, based on the metric which we keep track of. This will not affect the training procedure of the model.
You can train your model only with respect to some loss function. For example, cross entropy for classification problem. The readily available loss function in keras are given here
Precision, recall or f1-score are not differentialable functions. Hence, we cannot use that as a loss function for model training.
May be, if you want to tune your hyperparameter (such as learning rate, class weights) for improving f1 score, then you can be do that.
For tuning hyper parameters you can use hyperopt, tutorials
I'm going through the Keras autoencoder tutorial on this link and I noticed that, while all previous examples used all available cores on my machine, the example for the Convolutional autoencoder used a single core, therefore taking quite a bit longer than the previous examples.
I've trained it used the theano backend (as opposed to using tensorflow as suggested in the tutorial) though.
Is this expected behaviour or is something wrong here?