CNN for subsets of a dataset - how to tune hyperparameters

I have a dataset and would like to train CNNs on subsets of different size of the dataset. I already have a CNN, which classifies very well if I use the entire dataset. Now the question arises if I should really try to additionally optimize the parameters of the CNN for the subsets, regardless of whether I do Data Augmentation or not? Does it really make sense if I try to change the CNN model for the subsets by using …
Category: Data Science

Does high accuracy metrics with small (but equally sampled) dataset means a good model?

I have been training my CNN with 200 images per class for a classification problem. There problem is a binary classification one. And with the amount of test data ( 25 per class) I am getting good accuracy, precision and recall values. Does that mean my model is actually good?
Category: Data Science

False positive in Multi class Image classification

I am training a neural network with some convolution layers for multi class image classification. I am using keras to build and train the model. I am using 1600 images for all categories for training. I have used softmax as final layer activation function. The model predicts well on all True categories with high softmax probability. But when I test model on new or unknown data, it predicts with high softmax probability. How can I reduce that? Should I make …
Category: Data Science

Averaging multiple train-test splits to estimate the performance with higher variability?

I have a small size data set and I want to assess the effect of a certain type of cases on the overall model performance. For example, is the model biased against people of a certain age group? Using a single train-test split, the number of cases of a particular type becomes quite small, and I suspect findings may occur due to randomness. Would it in this scenario make sense to use multiple train-test splits, compute the average performances, and …
Category: Data Science

Keras model with 3 input images giving wrong output

I have created a keras model that takes 3 images as input, passes them to individual CNN backbone(mobilenet_v2) and fuse the results from 3 individual streams. These fused outputs further goes through a FCN and gives probability values for 10 classes. Now when i pass 3 images to my model using model.predict(), I am getting an output of 3x10 (list of 3 outputs with 10 values in each). Here is the network snapshot and here is the output *[[0.04718336 0.07464679 …
Category: Data Science

Val Loss and manually calculated loss produce different values

I have a CNN classification model that uses loss: binary cross entropy: optimizer_instance = Adam(learning_rate=learning_rate, decay=learning_rate / 200) model.compile(optimizer=optimizer_instance, loss='binary_crossentropy') We are saving the best model so the latest saved model is the one that achieved the best val_loss: es = EarlyStopping(monitor='val_loss', mode='min', verbose=0, patience=Config.LearningParameters.Patience) modelPath = modelFileFolder + Config.LearningParameters.ModelFileName checkpoint = keras.callbacks.ModelCheckpoint(modelPath , monitor='val_loss', save_best_only=True, save_weights_only=False, verbose=1) callbacks = [checkpoint,es] history = model.fit(x=training_generator, batch_size=Config.LearningParameters.Batch_size, epochs=Config.LearningParameters.Epochs, validation_data=validation_generator, callbacks=callbacks, verbose=1) on the course of the training the logs show that the …
Category: Data Science

Extract segment from document scan

I need to extract some "valuable" information from document scan. For example, document's number, incoming date, organizations, persons, etc. Example document: I'm trying to extract highlighted segment of the document. Original scan doesn't have that highlighting. And value can be handwritten or typewritten. I tried U-Net and Mask RCNN for my dataset (~100 examples). Without any success. Any ideas?
Category: Data Science

Understanding The Vertical and Horizontal stack in conditional gated Pixelcnn paper

I found some confusion understanding the importance of vertical and horizontal stacks as a solution to the blind spot problem presented in the original pixel cnn architecture discussed in this paper. The vertical and horizontal stacks ideas were presented in the this paper. Therefore, after browsing, I found this link to explain the concept. In the vertical stack section of the web page, I still find that pixel f, still cannot see pixels c, d and e. Any help is …
Category: Data Science

Classification problem in pytorch with loss function CrossEntropyLoss returns negative output in prediction

I am trying to train and predict SVHN dataset (VGG architecture). I get very high validate/test accuracy by just getting the largest output class. However, the output weights are of large positive and negative numbers. Are they supposed to parsed as exp(output)/sum(exp(output)) to be converted to probability? Thank you!
Topic: pytorch cnn
Category: Data Science

How to overcome importerror for tensorflow

I'm working on ubuntu, and i'm trying to train my python model but i receive the following error Traceback (most recent call last): File "trial.py", line 2, in <module> import tensorflow as tf ImportError: No module named tensorflow I've tried to install tensorflow via pip install tensorfow and ensure being installed via the following command pip show tensor and this is the output Name: tensorflow Version: 2.6.2 Summary: TensorFlow is an open source machine learning framework for everyone. Home-page: https://www.tensorflow.org/ …
Category: Data Science

My CNN image classification model gives good predictions in all but 2 classes. What should I do?

I built a CNN image classifier for a dataset that contains 6 classes. The dataset is balanced in all 6 classes. After training, the model gives pretty good prediction accuracy in all but 2 classes. To elaborate further, let us label these 6 classes with integers from '0' to '5'. The trained model does well in predicting classes from '0' to '3'. But almost 5%-10% of class '4' image is predicted as class '5' and similarly, 5%-10% of class '5' …
Category: Data Science

Neural Network is non deterministic on validation

We have a regression problem we are trying to solve. We are using Transfer learning by using resnet50 and adding a linear activation layer at the end of it. each image input is 3 layers of synthetic wavelet images (not RGB). since resent uses Relu as an activation function and the fact that the wavelet transformation produces negative values, we have shifted all the data of our images (3Dmatrix) to be positive our label data is between -5 and 5. …
Topic: cnn regression
Category: Data Science

Too many hours for Training Custom Object Detector

I am following this tutorial: https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html When I reach the training paragraph ( Training the Model ) and run this command: python3 model_main_tf2.py --model_dir=models/my_ssd_resnet50_v1_fpn --pipeline_config_path=models/my_ssd_resnet50_v1_fpn/pipeline.config I get mesages like this: Instructions for updating: `seed2` arg is deprecated.Use sample_distorted_bounding_box_v2 instead. W0128 18:24:29.575707 140532950755136 deprecation.py:341] From /usr/local/lib/python3.9/dist-packages/tensorflow/python/util/dispatch.py:1096: sample_distorted_bounding_box (from tensorflow.python.ops.image_ops_impl) is deprecated and will be removed in a future version. Instructions for updating: `seed2` arg is deprecated.Use sample_distorted_bounding_box_v2 instead. WARNING:tensorflow:From /usr/local/lib/python3.9/dist-packages/tensorflow/python/autograph/impl/api.py:465: to_float (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a …
Topic: cnn training
Category: Data Science

What are some general tips to improve my MNIST classifier?

I have built a CNN from scratch in python using Numpy, to tackle the MNIST hand-written digit recognition problem. It's composed out of a convolutional layer (3 3x3 filters), a maxpooling layer (2x2 pooling) and the 10-label output layer. I'm using softmax for the output activation function and cross-entropy as loss function. I've tried running it with a couple of different hyperparameters and so far the best accuracy i've gotten is 97%, when training on the whole train dataset (60000 …
Category: Data Science

how does convolutional layer work?

i have one question reagrding CNNs , if we take a signle convolutional layer it can have multiple filters right ? are these filters all the same ? is a single layer made only to detect one feature ? i'm a bit confused of the working of convolutional layer.
Category: Data Science

LeNet-5 - combining feature maps in C3 layer

Famous LeNet-5 architecture looks like this: The output of layer S2 has dimension: 10x10x6 - so basically an image with 6 convultions applied to it to derive features. If each dimension was again submitted to 6 filters the resulting output would be of 10x10x36 however it is 10x10x16. Initially I stumble on it but finnaly I udnerstood that this is done be combining inputs from layer S2 and applying one kernel on it as it's explained in the article: Layer …
Category: Data Science

Error on custom RNN/LSTM with multiple inputs

I want to implement a custom RNN/LSTM model similar to this. The model should take two separate vectors as input and process them. I was following keras tutorial to implement a custom keras layer and inputting two vectors a and b as a list [a,b] to the layer as shown below. import keras from keras.layers.recurrent import RNN import keras.backend as K class MinimalRNNCell(keras.layers.Layer): def __init__(self, units, **kwargs): self.units = units self.state_size = units super(MinimalRNNCell, self).__init__(**kwargs) def build(self, input_shape): print(type(input_shape)) self.kernel …
Category: Data Science

Need term or method name for evaluation of CNN without ground truth using e.g. a regression model

I have the following problem, I have trained a CNN and I can evaluate the network in-sample. I want to use the trained model for the class prediction of images for which I have no ground truth. However, there are other features referenced to these images that I can implement in a regression model along with predicted labels to predict Y. The only way to evaluate somehow the CNN is to infer if the predicted labels have an effect on …
Category: Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.