Pre-trained VGG-16 in MATLAB and PyTorch Same? - matlab

I have been trying to figure this out for some time but i am still a bit unsure. Does the PyTorch pre-trained VGG-16 (torchvision model) have exactly the same weights as the MATLAB pre-trained VGG-16?

If you are interested to find out, just take the norm of the weights in both libraries. I think they should be same.

Related

Layer in keras like regressionlayer in matlab?

I am trying to write the code in keras from already written Matlab Model in example here:https://in.mathworks.com/help/deeplearning/examples/denoise-speech-using-deep-learning-networks.html
They have defined a layer in the end called regressionLayer. I want to know what to use corresponding to this in keras or pytorch.
I have simply added the sigmoid activation rather than this regressionLayer in keras. But I doubt if this is correct because I dont seem to get the desired output and this seems to be one of the reason.
model.add(Conv2D(1, (129,1), strides =(1,100),padding='same',
input_shape=(129,8,18),activation='sigmoid'))
In Matlab the regression layer just computes a mean squared loss, which is the way Caffe works (losses as layers), but not the way Keras works, so the equivalent line would not be a layer, just setting the loss:
model.compile(loss='mse', optimizer=...)
Note that we do not include accuracy metrics if you are doing regression, as it is a classification only metric.

How to design 1D CNN in Matlab?

I am new to matlab and my project requires 1D Convolutional Neural Network. Can anyone tell me how to design 1D CNN in matlab? Does it require any special hardware? Refrence to some blogs will be really helpful.
Thank you.
As I know CNN implementation requires GPU. Matlab 2016 version have some inbuilt function but requires GPU installed to work. Python and tensorflow works great and quick , I would like you suggest to try those than Matlab.

SVM-Classification of multiclass

I've used Matlab Classification Learner App to train my SVM classifier and i have 99.9% of accuracy in prediction (i tested it with the function predict on matlab). What i wanted to do now was to predict without usind this function but using the hyperplane. I exported the trained classifier and so i have all the weights and the bias to find the hyperplane. Which formula should i use to predict new data? I tryed computing the sign of w'x but it works only in few cases. Can you help me understand what should i do?
Thanks a lot!

Matlab - Create RBF Network without using Neural Network Toolbox

In the lectures we only mention how to train the RBF network with Gausian function and how to use the "newrb" tool box in Matlab. But in the assignemnet I need to create my own RBF network which using the NN toolbox is forbidden. Basically I not even know how to start it and our professor not willing to provide any information.
With some tips I have write my own program but the performance is very bad, I am wonder if any one can give me some helpful tutorial or guides that how to create the RBF network with Gaussian function without using NN toolbox.
I have used k-means to obtain the centers and gaussian function to caculuate the weights, the main probrlem is that I have no idea how to design the method that transform the Input matrix to the RBF matrix. Hope you can help.
This is clearly homework, and it's not clear what your question is. But I think you are wondering how to create the Gram matrix. If so, see:
http://en.wikipedia.org/wiki/Gramian_matrix
You should have the math for how to do each step in your textbook and/or notes.

Matlab SVM training for muliclasses dataset

I have a question about the SVM MATLAB toolbox 2009b! the question is:
How I can train SVM classifier for classifying multi-classes datasets in MATLAB toolbox 2009b?
I just want to work with MATLAB toolbox, so please answer it if there is a way to implement it. For example, the below code is for classifying two classes datasets:
svmtrain( training data, ...
labels of training data, ...
'Kernel_Function', ...
'rbf', ...
'RBF_Sigma', ...
sigma value, ...
'Method', ...
'LS', ...
'BoxConstraint', ...
C ...
);
I want to know is there a way for training SVM for multi-classes dataset with writing a code such as above code, or should I write some code for training a SVM for each class versus the other classes?
It means, should I consider 1 for the label of the selected class and set the label of the other classes to 0, and train a SVM with above code, and do it for all classes!?
Thanks for your consideration :-)
I have not used SVM in Matlab, so other people can likely provide a more informed response, but I will share what I have learned.
Matlab Bioinformatics Toolbox SVM
From reading the documentation, the SVM in the Bioinformatics Toolbox appears to only support binary classification. As suggested in the question, a binary classifier can, with some effort, be used to classify into multiple classes. There is some discussion on approaches for doing this in the context of SVM here.
Alternate options
LIBSVM does support multi-class classification and comes with a Matlab interface. You could try installing and using it.
Additionally, while looking into this, I did come across several other Matlab toolboxes with SVM implementations. If LIBSVM is not a good option for you, it may be worth looking around to see if a different SVM implementation fits your needs.
If you have MATLAB release R2014b or later you can use the fitcecoc function in the Statistics and Machine Learning Toolbox to train a multi-class SVM.
Yup, the way for solving your problem - is to implement one vs all strategy. One of the SVM's lacks is that it has no direct multiclassification implementation.
But you can implement it through the binary classification.
I didn't see any function for svm multi classification in matlab. But i think it is not hard to implement it by yourself