Skip to content
This repository has been archived by the owner on May 6, 2023. It is now read-only.

Some questions about the code of the svm prediction part #27

Closed
anbo1024 opened this issue Jun 23, 2019 · 8 comments
Closed

Some questions about the code of the svm prediction part #27

anbo1024 opened this issue Jun 23, 2019 · 8 comments

Comments

@anbo1024
Copy link

This is the predicted output part of the svm network:
output = tf.identity(tf.sign(output), name='prediction')
correct_prediction = tf.equal(tf.argmax(output, 1), tf.argmax(y_input, 1))

After the output is processed by the function tf.sign(),a two-category tag that is processed into (1,-1).This is not predictable for multi-class handwritten data sets.
I want to ask you this question.

@AFAgarap
Copy link
Owner

@anbo1024 it can be used in a one-versus-all manner, i.e. in a one-hot encoded vector, instead of using 0 for the classes that a sample does not belong, we use -1 : [0, 1, 0, 0] --> [-1, 1, -1, 1]

@anbo1024
Copy link
Author

@AFAgarap I still have some doubts.
1、You will [0, 1, 0, 0] --> [-1, 1, -1, 1],Softmax regards the maximum subscript as the final classification result. How do you determine the final classification result with this encoding method?
2、I think that in CNN, whether using SVM or Softmax, the network output has been classified. SVM and Softmax calculate loss in different ways.

output = tf.identity(tf.sign(output), name='prediction')
output = tf.identity((output), name='prediction')
correct_prediction = tf.equal(tf.argmax(output, 1), tf.argmax(y_input, 1))

I think tf. sign and tf. nn. softmax functions can be removed.The following Correct_prediction function already contains the maximum operation.
I hope I can get your advice. Thank you very much.

@AFAgarap
Copy link
Owner

Well, in terms of having a one-hot encoded vector with a -1 in place of 0, e.g. [-1, 1, -1, -1], which one is greater, -1 or 1? 1, yes? So, it's still fine to be there. But you're right, it can be discarded for the purposes of getting the training accuracy.

@anbo1024
Copy link
Author

@AFAgarap I understand what you mean. Now, I use SVM as a loss function on my own dataset, but the performance is very poor, and Softmax performs very well. Why is this? Is the data still to be preprocessed?

@AFAgarap
Copy link
Owner

In Yichuan Tang's paper, Deep Learning using Linear Support Vector Machines, he used PCA and added Gaussian noise for MNIST. But that was on a feed-forward neural network with 2 layers having 512 units each.

@AFAgarap
Copy link
Owner

The paper is here

@anbo1024
Copy link
Author

Yes, I have read this article. Good results have been achieved in your code. Did you preprocess it?

@AFAgarap
Copy link
Owner

No, I didn't

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants