Implementing loss function in MatConvNet - matlab

I am trying to implement code for this loss function for a classification task for a subset image data using several pre-trained models provided by MatConvNet but not sure how to implement it.
average cross-entropy loss formula

Related

Neural Network Regression for Winequality Data [predicting density]

I am trying to run my neural network code but it showed an error. My code as per below.. wondering what i missed out. I am trying to predict the MSE value for the model and compare it with Linear regression.

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.

Is it possible to train classifier model in simulink?

I have a Simulink model where some features are extracted from the signals. I want to train a classifier model (LDA, kNN, etc.) with using these features. Is it possible to do it purely on Simulink? I want to do it on Simulink because, I am trying to simulate real-time online system that gives classification output causally.
I have tried to use fitcdscr and fitcknn functions in matlab function block. But they didn't work.

Random component on fitcsvm/predict

I have a train dataset and a test dataset, and I train a SVM with fitcsvm in MATLAB. Then, I proceed to test the trained model with predict. I'm always using the same datasets, but I keep getting different AUCs for the same model, which makes me wonder where in the process is there a random component. Note that
I'm aware of the fact that formally there isn't such thing as ROC curve or AUC and
I'm not asking for the statistical background of the SVM problem. It is relative to the matlab implementation of the training/test algorithm. I expected to have the same results because the training algorithm is, afaik, a deterministic process.

Applying Neural Network to forecast prices

I have read this line about neural networks :
"Although the perceptron rule finds a successful weight vector when
the training examples are linearly separable, it can fail to converge
if the examples are not linearly separable.
My data distribution is like this :The features are production of rubber ,consumption of rubber , production of synthetic rubber and exchange rate all values are scaled
My question is that the data is not linearly separable so should i apply ANN on it or not? is this a rule that it should be applied on linerly separable data only ? as i am getting good results using it (0.09% MAPE error) . I have also applied SVM regression (fitrsvm function in MATLAB)so I have to ask can SVM be used in forecasting /prediction or it is used only for classification I haven't read anywhere about using SVM to forecast , and the results for SVM are also not good what can be the possible reason?
Neural networks are not perceptrons. Perceptron is on of the oldest ideas, which is at most a single building block of neural networks. Perceptron is designed for binary, linear classification and your problem is neither the binary classification nor linearly separable. You are looking at regression here, where neural networks are a good fit.
can SVM be used in forecasting /prediction or it is used only for classification I haven't read anywhere about using SVM to forecast , and the results for SVM are also not good what can be the possible reason?
SVM has regression "clone" called SVR which can be used for any task NN (as a regressor) can be used. There are of course some typical characteristics of both (like SVR being non parametric estimator etc.). For the task at hand - both approaches (as well as any another regressor, there are dozens of them!) is fine.