Close Menu
    Trending
    • A sounding board for strengthening the student experience | MIT News
    • Revolutionize Research with Galambo — AI-Powered Image Search Tool | by Galambo | Jun, 2025
    • Optimizing DevOps for Large Enterprise Environments
    • 3 Signs You Are Ready to Sell Your Business
    • Combining technology, education, and human connection to improve online learning | MIT News
    • Building Google Veo 3 from Scratch Using Python | by Fareed Khan | Jun, 2025
    • Datavault AI to Deploy AI-Driven HPC for Biofuel R&D
    • Bezos-Sánchez Wedding Draws Business, Protests to Venice
    Finance StarGate
    • Home
    • Artificial Intelligence
    • AI Technology
    • Data Science
    • Machine Learning
    • Finance
    • Passive Income
    Finance StarGate
    Home»Machine Learning»Predicting Bird Species with Neural Network and Transfer Learning | by Manuel Cota | May, 2025
    Machine Learning

    Predicting Bird Species with Neural Network and Transfer Learning | by Manuel Cota | May, 2025

    FinanceStarGateBy FinanceStarGateMay 2, 2025No Comments4 Mins Read
    Share Facebook Twitter Pinterest LinkedIn Tumblr Reddit Telegram Email
    Share
    Facebook Twitter LinkedIn Pinterest Email


    On this mission, a mannequin was created to foretell the species of a hen in a given picture. The coaching dataset included 550 hen species. The ensuing Tensroflow mannequin had roughly 85% accuracy when predicting with new photographs.

    The supply code of the mission, in addition to the plots obtained, will be discovered within the GitHub repository.

    The hen photographs had been separated 80% for coaching and 20% for validation utilizing Keras to create separate directories. The photographs had been lowered to 160×160 pixels.

    BATCH_SIZE = 128
    IMG_SIZE = (160, 160)

    train_dataset = image_dataset_from_directory(
    listing,
    shuffle = True,
    batch_size = BATCH_SIZE,
    image_size = IMG_SIZE,
    validation_split = 0.2,
    subset = 'coaching',
    seed = 42
    )

    validation_dataset = image_dataset_from_directory(
    listing,
    shuffle = True,
    batch_size = BATCH_SIZE,
    image_size = IMG_SIZE,
    validation_split = 0.2,
    subset = 'validation',
    seed = 42
    )

    All photographs had been labeled with an integer quantity from 0 to 524 to characterize which of the 525 courses corresponded to a selected picture.

    To be able to do our mannequin, we primarily based it off of the ResNet50 mannequin. The mannequin has its personal preprocessing perform to be utilized to the enter knowledge. That method, our knowledge doesn’t want extra handbook preprocessing.

    IMG_SHAPE = IMG_SIZE + (3,)

    modelo_base_resnet = tf.keras.functions.resnet50.ResNet50(
    input_shape=IMG_SHAPE,
    include_top=False,
    weights='imagenet',
    )

    modelo_base_resnet.trainable = False

    inputs = tf.keras.Enter(form=IMG_SHAPE)
    x = tf.keras.functions.resnet50.preprocess_input( inputs )
    x = modelo_base_resnet(x,coaching=False)

    The mannequin was imported with out its high layers, in order that we will solely use their convolutional layers. The next layers had been added as the brand new high part:

    • Flatten Layer
    • Dropout Layer (0.5)
    • Dense (300 items, Relu activation)
    • Batch Normalization Layer
    • Output Layer (525 items, Linear activation)
    flatten          = Flatten()(x)
    drop = Dropout(0.5 )(flatten)
    dense1 = Dense(300, activation="relu")(drop)
    batch_norm_1 = BatchNormalization()(dense1)
    outputs = Dense( 525, activation='linear', identify = 'prediccion' )(batch_norm_1)

    modelo_resnet = tf.keras.Mannequin(inputs=inputs, outputs=outputs)

    We might have used Softmax activation within the output layer. Nevertheless, it’s extra computationally environment friendly to instantly use a linear activation, as an alternative of creating this system run a logistic perform time and again.

    The ultimate mannequin was compiled with an Adam optimizer and a Studying Price of 0.001. The loss perform was a Sparse Categorical Crossentropy perform utilizing logits (since we’re utilizing a Linear activation within the output layer as an alternative of a Softmax).

    Lastly, the metric to make use of as goal via the epochs was Accuracy.

    modelo_resnet.compile(
    optimizer = tf.keras.optimizers.Adam(learning_rate=0.001),
    loss = tf.keras.losses.SparseCategoricalCrossentropy(from_logits=True),
    metrics = ['accuracy']
    )

    First, the mannequin was skilled via 5 epochs, evaluating the practice accuracy with the validation accuracy. We additionally in contrast the loss from the coaching knowledge to the validation knowledge.

    Accuracy and loss for each the coaching and validation datasets all through the preliminary 5 epochs of coaching.

    Despite the fact that the coaching dataset obtained an accuracy of virtually 100%, the validation accuracy managed to remain at round 85% by the top. We are able to see within the loss comparability that the validation loss started to have a small tendency to diverge from the course of the coaching loss. In earlier makes an attempt, over-fitting was an issue. After some hyper-parameter tuning, this consequence was essentially the most optimum.

    To be able to try to enhance our mannequin, we did fantastic tuning by “unfreezing” among the final layers of the ResNet50 mannequin. The unique mannequin has round 150 layers. For this stage, we stored the primary 100 layers frozen and retrained the remaining, together with our custom-made high layers.

    The mannequin ran one other 5 epochs, ranging from the place it left off after the preliminary coaching. The hyper-parameters had been precisely the identical, specializing in the mannequin’s accuracy and loss.

    Accuracy and lack of each the coaching and validation datasets all through the entire 10 epochs of the mannequin’s coaching (each preliminary and fine-tuning intervals).

    Because the plot exhibits, the fine-tuning stored all the things at across the identical values after these further 5 epochs.

    On this specific mission, fine-tuning didn’t essentially made a huge effect within the mannequin’s accuracy. Nevertheless, we managed to create a brand new mannequin utilizing a preexisting mannequin (ResNet50). Switch studying proves to be a robust solution to create new fashions and functions.

    ResNet50 was skilled utilizing the ImageNet dataset, so the convolutional layers inside had been skilled with photographs of a variety of issues, not just some birds. Nevertheless, these layers had been skilled to distinguish between elementary constructions within the photographs. With switch studying, we will make use of these layers with out retraining them and with out losing extra effort and time.



    Source link

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    Previous ArticleAI Inference: Meta Teams with Cerebras on Llama API
    Next Article Build and Query Knowledge Graphs with LLMs
    FinanceStarGate

    Related Posts

    Machine Learning

    Revolutionize Research with Galambo — AI-Powered Image Search Tool | by Galambo | Jun, 2025

    June 18, 2025
    Machine Learning

    Building Google Veo 3 from Scratch Using Python | by Fareed Khan | Jun, 2025

    June 18, 2025
    Machine Learning

    AWS Made 10x Easier Using AI. Smart Tools Are upgrading Cloud… | by AI With Lil Bro | Jun, 2025

    June 18, 2025
    Add A Comment

    Comments are closed.

    Top Posts

    The Future of Filmmaking: How Generative AI is Transforming Video Production | by Felix Nguyen | Feb, 2025

    February 17, 2025

    A Terrible Life Insurance Mistake That Cost Me A Fortune

    June 11, 2025

    Free Webinar | March 11: 3 Biggest Mistakes Entrepreneurs Make (And How to Fix Them)

    February 20, 2025

    How AI is Shaping the Future of Climate Data Collection and Analysis

    February 19, 2025

    Reinforcement Learning, But With Rules: Meet the Temporal Gatekeeper | by Satyam Mishra | Jun, 2025

    June 8, 2025
    Categories
    • AI Technology
    • Artificial Intelligence
    • Data Science
    • Finance
    • Machine Learning
    • Passive Income
    Most Popular

    Edge Computing vs Cloud Computing: Cost Analysis

    March 1, 2025

    jdjdjdjdjjddjdj

    February 10, 2025

    From Lines to Classes: Wrapping Up Chapter 4 of Hands-On ML | by Khushi Rawat | Jun, 2025

    June 16, 2025
    Our Picks

    How Businesses Can Capitalize on Emerging Domain Name Trends

    February 27, 2025

    Introduction to Python. Code is a set of instructions to do… | by 桜満 集 | Feb, 2025

    February 17, 2025

    Barbara Corcoran: How to Get People to Respond to Your Email

    February 11, 2025
    Categories
    • AI Technology
    • Artificial Intelligence
    • Data Science
    • Finance
    • Machine Learning
    • Passive Income
    • Privacy Policy
    • Disclaimer
    • Terms and Conditions
    • About us
    • Contact us
    Copyright © 2025 Financestargate.com All Rights Reserved.

    Type above and press Enter to search. Press Esc to cancel.