top of page

Python Deep Learning Tips

As computational power is increasing almost daily so is the popularity of deep learning models.  Neural networks so an amazing ability to learn patterns and help in the automation of many tasks originally thought impossible for anything but a human.  There really isn't anything like deep learning and it can be a little tricky to get started with so we've designed these deep learning tips for the frameworks TensorFlow and Hugging Faces to help everyone become an Ai architect.  Learn how to build the best computer vision and NLP deep learning models.

TensorFlow Tips

TensorFlow Tips

Deep learning and artificial intelligence is the future.  TensorFlow is one of the most popular Python libraries for building your neural network.  Tensorflow has many built-in functions to help with ComputerVision or NLP type problems.  TensorFlow and be daunting to get started and these tips are designed to make the transition into Ai architecture a little easier.

Preprocessing

Tensorflow Architecture

In this free how-to section, we will cover how to use TensorFlow to preprocess our data.  You might be familiar with many techniques available in Pandas and DataFrame.  TensorFlow has many of the same utility functions for preprocessing our data to assist our deep learning model.  There are classic preprocessing functions that can be used on tabular data.  There are also many many functions available for preprocessing of text data for NLP problems and image data for computer vision problems.

tensorflow one hot encoding with to_categorical get_dummies

TensorFlow requires us to pay attention to how we put out categorical classification target into our model.  The to_categorical function in TensorFlow works in a similar way to the get_dummies function in Pandas.  And on a DataFrame can be used as a substitute.  Hot one encoding with TensorFlow requires use to give integers as our class.  If we use an sklearn preprocessing LabelEncoder and can then return these integers back into the original classes.

spare categorical crossentropy or categorical crossentropy when to use sparse or not tensorflow free python

TensorFlow is a powerful framework for building neural networks. With TensorFlow we can build deep-learning models that predict either a continuous variable or a categorical value.

 

We have the choice of either using Sparse Categorical Crossentropy or Categorical Crossentropy.

 

Inside our model, it wouldn't make a difference for training only how we put the data into our model.

Deep Learning Architecture

Tensorflow Architecture

The architecture of your deep learning model is no simple thing.  The reason is we have so so much flexiblity in how we design our deep learning architecture that it's help to understand popular and famous neural network architecture. In Python with Tensorflow learning how to build neural networks with the Sequential and Functional APIs.

Whether you're a beginner or a seasoned data scientist, understanding these two paradigms will equip you with the skills to create, train, and deploy deep learning models for a wide range of applications. So, let's embark on this exciting journey of learning and discover how to harness the true potential of TensorFlow through practical examples using both the Sequential and Functional APIs.

Sequential API

free example perceptron in tensorflow python

The perceptron model was the first and simplest type of neural network developed back in 1943. It works well but certainly far from modern nueral networks with advanced layers such as the recurrent layer. In Python using Tensorflow with the sequential api the the build a nueral network in the style of a perceptron.  

feed forward network in tensorflow python free how to

In Python using Tensorflow design a Feed Forward neural network to predict a regression problem expand on the perceptron and by adding more dense fully connected layers.  You will find that only adding more Dense fully connected layers doesn't unlock the true power of neural networks.  

TensorFlow Deep Forward Neural Network

In Python use Tensorflow to build a deep forward deep learning architecture.  The problem with such a long network is finding the correct hyperparameters that will make it work.  So many dense layers has the potential problem of confusing our network and it won't be able to make good predictions. 

free how to build different convoluation neural network architecture examples conv
tensorflow flow how to build recurren neural network free

A recurrent neural network (RNN) is a type of artificial neural network designed to process sequential data by considering the previous information along with the current input. Unlike feedforward neural networks, which process data in a single forward pass, RNNs have a feedback mechanism that allows them to maintain an internal memory or state. This memory enables RNNs to retain information about the sequence they have processed so far, making them well-suited for tasks that involve time-series data or sequences of varying lengths.  We will cover the SimpleRNN, GRU and LSTM recurrent layers.

A convolutional network in TensorFlow's sequential model is a specialized type of neural network commonly used for image analysis tasks. It utilizes convolutional layers to detect patterns and features in images, which are then passed through activation functions to capture nonlinear relationships. The sequential model in TensorFlow provides a convenient and intuitive way to stack these layers sequentially, allowing for efficient training and inference on image data.

Functional Api

Tensorflow Architecture

The Functional API in TensorFlow offers a flexible and dynamic approach to building neural networks, enabling non-linear architectures with multiple inputs and outputs, shared layers, and skip connections. Its explicit data flow and named layers enhance model readability and maintainability, fostering collaboration and ease of modification. Moreover, the API promotes code reuse and modularity, saving time and ensuring consistency across experiments. It aligns with functional programming principles, allowing for the implementation of custom loss functions, layers, and training loops, empowering researchers and developers to explore innovative ideas. With its versatility and intuitiveness, the Functional API stands as a powerful choice for constructing diverse neural network models and efficiently addressing a wide range of machine learning tasks.

free python deep learning how to build a convolutional nueral network in with TensorFlow in python free python code examples

4

How to Build a Convolutional Neural Network in Python with Tensorflow Functional API

In Python use Tensorflow

free costless independent education on how to build a tensorflow preceptron in the funcitonal API

1

How to Build a Perceptron in TensorFlow Functional API

Deep learning is at the heart of many cutting-edge applications, from computer vision to natural language processing. With Python as our weapon of choice and TensorFlow as our powerhouse, we're diving deep into building a Perceptron—an elementary yet crucial building block of artificial neural networks. Learn how to build the preceptor architecture with TensorFlow

feed forward network with tensorflow funcitonal api learn independently for free costless educational material for deep learning python

3

How to Build a Feed Forward with TensorFlow Functional API

Learn how to build the feed forward architecture and how using the functional API in TensorFlow we can have add Multiple Inputs or Outputs to our Deep Learning model with the Functional API

Hugging Faces Tips

Hugging Faces Tips

Hugging Faces which is the company behind the transformers library gives you access to many prebuilt transformer models like DistilBert, GPT2, BERT, RoFormer, and Electra and many many more.  The Hugging Faces, transformers, library can be implemented with either TensorFlow or PyTorch.  Hugging Faces has prebuilt models for NLP problems such as text classification and text generation and questioning and answering.  Transformers also give use access to models built for computer vision classification or image generation tasks as with as audio classification.  Let's explore how to implement transformer models with Hugging Faces.   

NLP

How to Fine Tuning Hugging Faces Transformers in Python for NLP Classification

Learn how to fine-tune the transformer models  Roberta, Electra, and BERT, T5, and Alberta in Python in this free beginner intro to fine tuning with hugging faces with a simple NLP classification problem. In this free Python educational lesson, we will use transformers' Auto Model class to easily import each different model with similar Python code.  This pairs nicely with the Auto Tokenizer which helps ensure our texts are tokenized in the appropriate format for each model without having to import a separate tokenizer or model function.  


Using the Auto Model and Auto Tokenizer makes setting up experiments in with transforms so much faster and easier.


Here we Fine Tune these various sequence classification model on a New Articles classification problem with 4 classes.  To show the effect of fine tuning with will look at the model's accuracy and confusion matrix first without fine tuning and then again after we h have completed fine tuning.  In these free Python lesson we will be training these models for only 3 epochs and it's amazing the effect of such a short training time on the final accuracy. 

NLP

Simple Introduction to Hugging Faces NLP Pipelines in Python Classification Text Generation

In the lesson we will introduce NLP Pipelines in Hugging Faces.  We will show how to use a transformers pipeline for sentiment classification to start.  And then show how the pipeline can be used to classify different texts in any number of different categories with incredible ease with zero-shot classification.  The value of pipelines is that they combine the tokenization and model and then the decoding into one very very easy-to-use function.  


With pipelines, we'll have the flexibility to use the many different models as well.  From GPT2, RoBerta, BERT, and one our favorite Electra.  Pipelines will handle the individual tokenization specific to each model and then the return to use the sentiment, the classification, and even the generated text


Learn how simple and easy it is to use the a Hugging Faces Pipeline in the free Python machine-learning class. 

NLP

Working with Hugging Faces NLP Dataset

In this Hugging Faces Tips Video we will use Python and learn how to manipulate and explore a Transformers dataset.  First we need to know how to load a dataset from Hugging Faces Hub and we will show you how to do this and then load the data with the datasets library. 

NLP

Difference Between Tokenizer and TokenizerFast with Hugging Faces transformers

To Tokenizer or TokenizerFast? What's the difference between these two tokenizers in Hugging Faces transformer library and when would it make sense to use one versus the other?    We'll use a 650,000 row, Yelp Review, dataset to compare the speed of each tokenizer and see if Fast really means faster.  In this lesson, we will use ElectraTokenizer and ElectraFastTokenizer although the would work with any of the models in Hugging Faces that have the fast version available.  We'll also show you how to decode the input ids back to words after tokenization.

NLP

Hugging Faces For Sequences Classification NLP with TensorFlow

Transformers have proven themselves as crucial in many Deep Learning tasks such as text classification in an NLP problem.  Here we will use a dataset from Hugging Faces dataset library and train For Sequences classification versions of the Roberta, Electra, XLNet, Deberta, RoFormer, and BERT transformer models.  We will compare how each of these models did by comparing the accuracy of train and test predictions.   We'll also be comparing training times.  We look at retraining only the classification output layer and then training the entire model including the transformer to see the final results.

bottom of page