# Tag Info

4

Short answer: Generally, you don't need to do softmax if you don't need probabilities. And using raw logits leads to more numerically stable code. Long answer: First of all, the inputs of the softmax layer are called logits. During evaluation, if you are only interested in the highest-probability class, then you can do argmax(vec) on the logits. If you want ...

3

The usual way to implement this would be to add the new class with data examples. Some things you need to address: Sourcing new data for your "other" class. Ensuring the amount and variation of data in "other" class examples matches how the predictor will be used. Code examples for this are not necessary, as you would just use the same network design as ...

3

You can introduce another class to your network - "not a book". After that, you will need to add new data to your dataset, random images that do not contain books to classify and train your network on that data. So when your network won't see a book it will output high probability for "not a book" class, if an image with a book will be shown to the network ...

2

Let's say we have $K$ classes. For $K$ classes, we will be training $K$ different neural networks. No, you still train one network. With binary classification tasks, where you have only two mutually exclusive categories, like "yes/no" or "true/false", you can get away with a single output node with a sigmoid activation. The output of the ...

2

Let us suppose that you are training a neural network for classfing images of vehicles , then the input vector , image of the "vehicle" will be a 2D array of pixels. This undergoes several transformations at each layer of the neural network , the last layer of the neural network produces another vector whose dimensions are lesser than the original image ...

2

If you are using a softmax distribution for your classification, then you could determine what your baseline max probability is for correctly classified samples, and then infer if a new sample doesn't belong to any of your known classes if its max probability is below some kind of threshold. This idea comes from a research paper that does a much better job ...

2

Neural networks use random number generators in multiple places. Most notably for weight initialisation, but also for features such as dropout, selecting minibatches within epochs, and train/cv split for cross-validation. That means that any result metric from the neural network e.g. accuracy, loss, F1 score, is a random variable. Reporting a single value of ...

1

I think a custom loss function would be an overkill in this situation. A linear pattern like this would be easily learned by any loss desinged for multi class classification. If I were you I would try 3 roads, in this order: train a classifier based on decision trees (random forest & xgboost in primis). The rule you described would most likely be ...

1

I am not really a fan of the One vs All approach. From my experience it is never convenient to transform a multi-class classification problem with, say, $N$ possible classes to a bunch of binary classification problems. Reason #1 The number of binary classifiers you need to train scales linearly with the number of classes. Hence, you can easily find ...

1

For pretrained models in NLP, look at BERT and RoBERTa. If you can find a language model trained on your data's superset on Huggingface, then, use that pretrained model. In order to multiclass classification, since your data is less, look at augmentations in NLP (most notably, backtranslation amongst others). Use focal loss (to handle class imbalance). Since,...

1

Your call to model.predict() is returning the logits for softmax. This is useful for training purposes. To get probabilties, you need to apply softmax on the logits. import torch.nn.functional as F logits = model.predict() probabilities = F.softmax(logits, dim=-1) Now you can apply your threshold same as for the Keras model.

Only top voted, non community-wiki answers of a minimum length are eligible