Training Inception V3 based model using Keras with Tensorflow Backend

I am currently training a few custom models that require about 12Gb GPU memory at the most. My setup has about 96Gb of GPU memory and python/Jupyter still manages to hog up all the gpu memory to the point that I get the Resource exhausted error thrown at me. I am stuck at this peculiar issue for a while and hence any help will be appreciated. Now, when loading a vgg based model similar to this: from keras.applications.vgg16 import VGG16 …
Category: Data Science

Is there wights of voice or audio for VGG or Inception?

I want to use VGG16 (or VGG19) for voice clustering task. I read some articles which suggest to use VGG (16 or 19) in order to build the embedding vector for the clustering algorithm. The process is to convert the wav file into mfcc or plot (Amp vs Time) and use this as input to VGG model. I tried it out with VGG19 (and weights='imagenet'). I got bad results, and I assumed it because I'm using VGG with wrong weights …
Category: Data Science

What is the reason behind the minimum image size in the Keras InceptionResNetV2 model?

In Keras' documentation for the InceptionResNetV2 model, it says the following: input_shape: (...). It should have exactly 3 inputs channels, and width and height should be no smaller than 139. I'm trying to figure out the reason behind the minimum size of 139px for this model, because I'm looking to train this model on smaller images (128px for starters). I can't find any clues in the model's source code or in the paper which describes the model. Assuming this number …
Category: Data Science

Running Tensorflow MobileNet from Java

I am trying to run Tensorflow for image recognition (classification) in Java (JSE not Android). I am using the code from here, and here. It works for Inceptionv3 models, and for models retrained from Inceptionv3. But for MobileNet models, it does not work, (such as following this article). The code works but gives the wrong results (wrong classify labels). What code/settings are required to use MobileNet from Java? The code that works for Inceptionv3 is try (Tensor image = Tensor.create(imageBytes)) …
Category: Data Science

When i'm training the pre-trained model on kaggle dataset, it is showing 79% accuracy. when i test on different dataset it shows 42% accuracy

This is the code i used to train the pre-trained model 'inception v3'. And can i know it is showing accuracy as 0.8717 but the val_accuracy as 0.7781. why there is a that much difference. Can anyone explain where it is training correctly or not. If not, can anyone suggest me what wrong is happening? Thanks in advance below is the Code: D:\NEW_DRD\Scripts\python.exe D:/NEW_DRD/own_model.py 2022-04-11 05:58:26.638080: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found 2022-04-11 05:58:26.639003: …
Category: Data Science

Number of input and output channels of MAX POOL layer

This is what Andrew Ng draws in his pooling layers video in the Coursera Deep Learning Specialization: and this is what he draws in Inception network video: Notice in first slide, number of input and output channels is same as pooling layers processes each channel independently and thus produces as many output channels as there are in the input. But in the second slide, the number of output and input channels of the MAX-POOL is different: number of input channels …
Category: Data Science

Error when trying Transfer Learning

I'm trying to train a model which is an extension of Google's Inception-V3 for the purpose of recognizing and classifying whether there is any pneumonia using x-ray images. I've used Tensorflow-Hub to get through the transfer-learning part, the code snippet is as follows: import tensorflow_hub as hub module_selection = ("inception_v3", 1200, 2048) handle_base, pixels, FV_SIZE = module_selection MODULE_HANDLE = "https://tfhub.dev/google/tf2-preview/{}/feature_vector/4".format(handle_base) IMAGE_SIZE = (pixels, pixels) print("Using {} with input size {} and output dimension {}".format(MODULE_HANDLE, IMAGE_SIZE, FV_SIZE)) do_fine_tuning = False feature_extractor …
Category: Data Science

Ignore Inception Model Auxiliary Loss during Inference

For inception model v1, the authors used auxiliary loss to avoid vanishing problem. So they added 2 auxiliary loss to help train their model as you see in the purple boxes below, but they did not use these during inference. Problem: Once you train a model, you will save it along with its weights to do inference against new data, so I am not sure how they ignore that given that a model will be saved with all of its …
Category: Data Science

python.framework.errors_impl.permissiondeniederror

I am trying to retrain inception final layer on new set of images. I am using docker TensorFlow image on Windows environment. Below are the steps that I am following. Install docker toolbox for windows. Pulling the tensorflow docker image. docker run -it gcr.io/tensorflow/tensorflow:latest-devel Linking tensorflow to the folder on host machine where new set of images are stored. docker run -it -v "$(pwd)":/tf_files/samples gcr.io/tensorflow/tensorflow:latest-devel tf_files/samples contains the set of images on which I want to retrain the model. cd …
Category: Data Science

Q. Why is my testing accuracy varying slightly with batch size (97.7% - 100%)?

As you will see, when batch size is set to 1, I'm consistently getting 97.7% testing accuracy for all 10 iterations. However, when batch size is set to 64, I'm getting a testing accuracy of 100% 7 out of 10 times and 95% the remaining 3 times. So why is this happening? Something to do with Batch Norm? What batch size should I always set when testing a Transfer Learning model regardless of the size of the testing dataset(i.e., no …
Category: Data Science

I'm trying to use InceptionV3 as a pre-trained feature extractor for shorthand writing image captioning, am I on the right track?

I'm new to AI and I'm trying to understand image captioning for a project that I'm working on. I'm trying to build a translator for Gregg shorthand writing. I'd be feeding pictures of individual Gregg words to the model and make it guess what letters are present in the image. So far I understand that I need a feature extractor, and InceptionV3 is looking good as an option but I wan't to make sure that I'm doing it right. Would …
Category: Data Science

Are imagenet weights same for all pretrained models?

I am new to transfer learning and I have one image classification problem, and I was thinking about training two pretrained model on TensorFlow: Inception and NASNet. Inc_net = InceptionV3(input_shape = (300, 300, 3), include_top= False, weights = "imagenet") nas_net = NASNetLarge(input_shape = (331, 331, 3), include_top = False, weights = "imagenet") but I am using same weights for both i.e. 'imagenet'. My question is, if both of my models have same imagenet weights, and both models are non-trainable, will …
Category: Data Science

Testing accuracy very low, while training and validation accuracy ~ 85%

I have a training dataset of 10000 pictures and a test dataset of 15000 pictures. There are 23 types of birds. First of all, I imported the necessary import tensorflow as tf from tensorflow import keras from tensorflow.keras.preprocessing.image import ImageDataGenerator from tensorflow.keras import layers from tensorflow.keras import Model import matplotlib.pyplot as plt from keras.applications.inception_v3 import InceptionV3, preprocess_input batch_size = 32 IM_WIDTH, IM_HEIGHT = 150, 150 # fixed size for inceptionV3 nb_epochs = 13 train_dir = '/kaggle/output/working_directory/' I am using ImageDataGenerator …
Category: Data Science

What is the difference between Inception v2 and Inception v3?

The paper Going deeper with convolutions describes GoogleNet which contains the original inception modules: The change to inception v2 was that they replaced the 5x5 convolutions by two successive 3x3 convolutions and applied pooling: What is the difference between Inception v2 and Inception v3?
Category: Data Science

Inception V3 Running Stats?

Has anyone created statistics on how fast and accurate Inception V3 can classify an image based on criteria such as: different models of GPUs/CPUs, input image size, input image ratio, file format, how it runs on iOS and Android, etc? Example chart I'd hope to see: GPU | CPU | Ratio | Size | Speed | Accuracy x 1:1 100x100 1000ms 93% x 3:4 3k x 4k 40000ms 95% X as in type of GPU/ CPU
Category: Data Science

How does inception decrease the computational cost?

From the second paragraph of 3.1 Factorization into smaller convolution in the paper Rethinking the inception architecture for computer vision: This setup clearly reduces the parameter count by shar- ing the weights between adjacent tiles. To analyze the expected computational cost savings, ... This way, we end up with a net 9+9 × reduction of computation, resulting 25 in a relative gain of 28% by this factorization Apprantly this design decreases the number of parameters. But I can't understand why …
Category: Data Science

About multiple objectives in Inception networks

Inception networks, in contrast to most of the networks, can have multiple outputs, from which the gradient can propagate in order to update the weights. These outputs can have different size and solve different tasks. Do I correctly understand, that the main point in doing so, that the common for both output heads part of the CNN learns useful information from both inputs simultaneously? To get something sensible, these two tasks most likely need to correlate in a certain way, …
Category: Data Science

Dealing with pre-trained model for grayscale images

I would like to do Transfer Learning using one of the novel networks such as VGG, ResNet, Inception, etc. The problem is that my images are grayscale (1 channel) since all the above mentioned models were trained on ImageNet dataset (which consists of RGB images). One of the solutions is to repeat the image array 3 times to make it 3 channel. Is this really the only solution for that? Is it a good solution? Are there any other solutions?
Category: Data Science

Very Fast Training After First Epoch

I trained an InceptionV3 model using plant images. I used Keras library. When training was started, first epoch took 29s per step and then other steps took approximately 530ms per step. So that made me doubt whether there is a bug in my code. I checked my code several times, but its logic seems right to me. I trained my model on Google Colab. I wonder whether there is a memoization mechanism or my code contains bugs. Here my code: …
Category: Data Science

About

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