Skip to content

Introduction to the basic notions that involve the concept of Machine Learning and Deep Learning. Linear Regression, Logistic Regression, Artificial Neural Networks, Deep Neural Networks, Convolutional Neural Networks.

License

Notifications You must be signed in to change notification settings

mafda/deep_learning_101

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deep Learning 101

This repository presents the basic notions that involve the concept of Machine Learning and Deep Learning.

Read more in this post ML & DL — Machine Learning and Deep Learning 101.

Configure environment

  • Create the conda environment
(base)$: conda env create -f environment.yml

Mac OS users could use the environment_ios.yml file for configuring the iOS development environment.

  • Activate the environment
(base)$: conda activate deep_learning_101
  • Run!
(deep_learning_101)$: python -m jupyter notebook

Models

The models include a brief theoretical introduction and practical implementations developed using Python and Keras/TensorFlow in Jupyter Notebooks.

Development Environment:

The development environment that will be used as one of the primary frameworks for machine learning and deep learning, alongside Python programming, is the Jupyter Notebook environment.

keras flow

1. Load Data

Load data (training and testing set):

import tensorflow as tf

X_train, y_train = tf.keras.datasets.mnist.load_data()
X_test, y_test = tf.keras.datasets.mnist.load_data()

2. Define Model

Two models: Sequential and Functional API.

Sequential used to stack layers:

  • model.add() used to add the layers.
  • input_shape =() specify the input form.
model = tf.keras.models.Sequential()
model.add(layer1 …, input_shape=(nFeatures))
model.add(layer2 … )

3. Compile Model

Configure the learning process by specifying:

model.compile(optimizer='SGD', loss='mse', metrics=['accuracy'])

4. Fit Model

Start the training process.

  • batch_size: divide the data set into a number of batches.
  • epochs: number of times the data set is trained completely.
model.fit(X_train, y_train, batch_size=500, epochs=1)

5. Evaluate Model

Evaluate the performance of the model.

  • model.evaluate() finds the specified loss and metrics, and it provides a quantitative measure of accuracy.
  • model.predict() finds the output for the provided test data and it is useful to check the outputs qualitatively.
history = model.evaluate(X_test, y_test)
y_pred = model.predict(X_test)

Accuracy results

Model Architecture Activation Parameters Accuracy
LogReg -- -- 7850 0.9282
ANN [32] [sigmoid] 25450 0.9636
DNN [128, 64] [relu, relu] 25450 0.9801
CNN [32, 64, 128] [relu, relu, relu] 25450 0.9898

Target - Hypothesis - Cost

Model Target Hypothesis Cost
LinReg Continuous $\hat{y}=Wx+b$ MSE
LogReg Categorical $\hat{y}=\sigma(Wx+b)$ Cross-Entropy
ANN Continuous, Categorical $\hat{y}=f_{(2)}(f_{(1)}(x))$ MSE, Cross-entropy
DNN Continuous, Categorical $\hat{y}=f_{(n)}(...f_{(2)}(f_{(1)}(x)))$ MSE, Cross-entropy
CNN Continuous, Categorical $\hat{y}=f_{(n)}(...f_{(2)(\ast)}(f_{(1)(\ast)}(x)))$ MSE, Cross-entropy

Theoretical introduction (https://mafda.medium.com):

Practical implementations (Jupyter Notebooks):

[pt-BR] Presentation

References


made with 💙 by mafda