Code Monkey home page Code Monkey logo

deep-learning-experiments's Introduction

Deep Learning Lecture Notes and Experiments

2023 Version (latest)

Revised and expanded

Theory

Topic Note Video Code
Overview PDF - -
Supervised Learning PDF - -
Multilayer Perceptron (MLP) PDF - -
Optimization PDF - -
Regularization PDF - -
CNN PDF - Notebook
Transformer PDF - Notebook
Autoencoder (AE) PDF - AE & Denoising AE
Colorization AE
Variational Autoencoder (VAE) PDF - VAE and CVAE
Generative Adversarial Network (GAN) PDF - DCGAN and CGAN
Intro to Large Language Models (LLMs) PDF - -
LLM Data and Model PDF - -

Practice

Topic Note Video Code
Development Environment PDF - -
Python PDF - -
Numpy PDF - -
PyTorch PDF - -
Gradio PDF - Notebook
Efficiency PDF - Code
PyTorch Lightning PDF - Notebook
Model Packaging & Serving PDF - ONNX Export
ONNX Runtime
TorchScript & TensorRT
PyTriton Yolo Client
PyTriton Yolo Server
Docker PDF = -
HuggingFcae PDF - -

Experiments on LLMs, LVMs and Agents

AI, ML and Deep Learning Note Video Code
LLM
    LangChain PDF - Jupyter
    LLM Fine Tuning & Document Query PDF - Jupyter
    Document Query using Chroma - - Jupyter
    Dolly (Free LLM) - - Jupyter
LVM
    Segment Anything Model (SAM) PDF - Prompts &
All Masks
     Open CLIP & CoCa - - Jupyter
Agents
     HuggingGPT PDF - Agents
Large MultiModal Models (L3M)
     ImageBind PDF - ImageBind
Stable Diffusion
     Diffusion - - Diffusers
     ControlNet - - ControlNet

2022 Version

Welcome to the 2022 version of Deep Learning course. We made major changes in the coverage and delivery of this course to reflect the recent advances in the field.

Install

Assuming you already have anaconda or venv, install the required python packages to run the experiments in this version.

pip install -r requirements.txt

Coverage:

AI, ML and Deep Learning Note Video Code
    Overview PDF YouTube -
Toolkit
    Development Environment
    and Code Editor
PDF YouTube -
    Python PDF YouTube -
    Numpy PDF YouTube Jupyter
    Einsum PDF YouTube Jupyter
    Einops PDF YouTube Jupyter &
Jupyter (Audio)
    PyTorch & Timm PDF YouTube PyTorch/Timm &
Input Jupyter
    Gradio & Hugging Face PDF YouTube Jupyter
    Weights and Biases PDF YouTube Jupyter
    Hugging Face Accelerator Same as W&B Same as W&B Jupyter &
Python
Datasets & Dataloaders PDF YouTube Jupyter
Supervised Learning PDF YouTube
    PyTorch Lightning PDF YouTube MNIST & KWS
    Keyword Spotting App cd versions/2022/supervised/python &&
python3 kws-infer.py --gui
Building blocks:
MLPs, CNNs, RNNs, Transformers
    MLP PDF YouTube MLP on CIFAR10
    CNN PDF YouTube CNN on CIFAR10
    Transformer PDF YouTube Transformer on CIFAR10
Backpropagation PDF
Optimization PDF
Regularization PDF
Unsupervised Learning Soon
AutoEncoders PDF YouTube AE MNIST
Colorization CIFAR10
Variational AutoEncoders Soon
Practical Applications:
Vision, Speech, NLP
Soon

What is new in 2022 version:

  1. Emphasis on tools to use and deploy deep learning models. In the past, we learn how to build and train models to perform certain tasks. However, often times we want to use a pre-trained model for immediate deployment. testing or demonstration. Hence, we will use tools such as huggingface, gradio and streamlit in our discussions.

  2. Emphasis on understanding deep learning building blocks. The ability to build, train and test models is important. However, when we want to optimize and deploy a deep learning model on a new hardware or run it on production, we need an in-depth understanding of the code implementation of our algorithms. Hence, there will be emphasis on low-level algorithms and their code implementations.

  3. Emphasis on practical applications. Deep learning can do a lot more than recognition. Hence, we will highlight practical applications in vision (detection, segmentation), speech (ASR, TTS) and text (sentiment, summarization).

  4. Various levels of abstraction. We will present deep learning concepts from low-level numpy and einops, to mid-level framework such as PyTorch, and to high-level APIs such as huggingface, gradio and streamlit. This enables us to use deep learning principles depending on the problem constraints.

  5. Emphasis on individual presentation of assignments, machine exercises and projects. Online learning is hard. To maximize student learning, this course focuses on exchange of ideas to ensure individual student progress.

Star, Fork, Cite

If you find this work useful, please give it a star, fork, or cite:

@misc{atienza2020dl,
  title={Deep Learning Lecture Notes},
  author={Atienza, Rowel},
  year={2020},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/roatienza/Deep-Learning-Experiments}},
}

deep-learning-experiments's People

Contributors

roatienza avatar shubajitsaha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

deep-learning-experiments's Issues

Freezing the Discriminator

Hi, thank you very much for this wonderful example for implementing GAN using Keras.
I have one question, based on what I understood from the theory that there are three stages GAN should be train with:

  1. training D for ground truth data as input with label 1 as output
  2. training D using G output as an input and label 0 as output
  3. same as (2) but with freezing D weights and label 1 as D output
    my question is: I didn't see any freezing step in your code. So, is that deferent way of implementation? or I miss something?
    Thanks again

Adviсe about keras GAN

I'm trying on the basis of your example make a generator of color images.
But missing something with the color dimension.
And get error:
number of input channels does not match corresponding dimension of filter, 1 != 3

Code
https://pastebin.com/TAm21NJg

Use Code In A loop

I want to use this code in a loop, but I am getting a ValueError due to Tensorflow variable sharing problem. I am unable to fix it, can you help?

dcgan loss

in
https://github.com/roatienza/Deep-Learning-Experiments/blob/master/Experiments/Tensorflow/GAN/dcgan_mnist.py
you compute the generator loss as:
a_loss = self.adversarial.train_on_batch(noise, y)
but this also trains the discriminator using only the fake samples.
shouldn't you freeze the discriminator weights for this part?

rnn_words.py: unhashable type: 'list'

Loaded training data...
Traceback (most recent call last):
File "rnn_words.py", line 56, in
dictionary, reverse_dictionary = build_dataset(training_data)
File "rnn_words.py", line 49, in build_dataset
count = collections.Counter(words).most_common()
File "/usr/lib64/python2.7/collections.py", line 444, in init
self.update(iterable, **kwds)
File "/usr/lib64/python2.7/collections.py", line 526, in update
self[elem] = self_get(elem, 0) + 1
TypeError: unhashable type: 'list'

I searched the web but do not solve it, anyone can help me?

Is it necessary to use use a different class than the DCGAN class to build GAN

I was trying to implement https://github.com/roatienza/Deep-Learning-Experiments/blob/master/Experiments/Tensorflow/GAN/dcgan_mnist.py and it works fine. But I tried the exact same code without the wrapper class ie I wrote just one class DCGAN and tried to build D, G and AM in the same class through various functions. I came across very weird Keras errors like TypeError: __call__() missing 1 required positional argument: 'inputs' for the line

. Does this mean the Keras's Sequential object is stateful and changes usage based on whether it is used in the same class or different one?

Also, I noticed that there's a lot of duct-tape code like

 if self.D:
    return self.D

This pattern is repeated whenever you create a D/G/AM model. Why is this. Is this related to the other questions I raised?

dcgan loss puzzle

in
https://github.com/roatienza/Deep-Learning-Experiments/blob/master/Experiments/Tensorflow/GAN/dcgan_mnist.py
you compute the discriminator loss as:

images_fake = self.generator.predict(noise)
x = np.concatenate((images_train, images_fake))
y = np.ones([2*batch_size, 1])
y[batch_size:, :] = 0
d_loss = self.discriminator.train_on_batch(x, y)

y[batch_size:, :] = 0 is this wrong?I think it is y[batch_size:, :] = 1

How long does it take to run 10K iterations?

How long does it take to run 10K iterations on a 2.7 GHZ intel Core i5 processor Mac book?

I was at 150 iterations after so many hours? Is there a problem with code, system or I need a GPU?

Feature extraction

@roatienza how to use this code for own dataset or other dataset like celeba as feature extractor use the discriminator network?

Error when feeding Cifar-1o dataset

When i use cifar 10 as input to the same code, i get this error
ValueError: number of input channels does not match corresponding dimension of filter, 1 != 3

Optimization in Deep Learning

image

Hello. Prof Atienza. You said here (Lecture 3, Slide 23) that we can only use gradient descent in optimizing deep learning models (particularly loss function). I understand that both closed-form solution and Newton's method are computationally painful to use, that non-iterative 1st order optimization is inefficient, and that convex optimization is also not an option since most deep learning models have multiple extremas. We are therefore left only with gradient descent.

Are there other approaches to optimization in deep learning?

memory Error

Hi,
When I increase the size of the file I see I am getting memory Error.

Looks

content = np.array(content)

is not able to get more data into the buffer (100MB Text file).
is there a way (or) any suggestions to make this same program work for large amount of data

D&A loss & acc fixed and dead,why?

I just run this python program of DCGAN with keras, it seems work and after 20 mins, all outputs and numbers are fixed and NEVER changed again, it seems dead, but WHY? output is copied below:

48: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
49: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
50: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
51: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
52: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
53: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
54: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
55: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
56: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
57: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
58: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
59: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
60: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
61: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
62: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
63: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
64: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
65: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
66: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]
67: [D loss: 7.971192, acc: 0.500000] [A loss: 0.000000, acc: 1.000000]

module 'tensorflow.python.ops.nn' has no attribute 'leaky_relu'

AttributeError Traceback (most recent call last)
in ()
190
191 if name == 'main':
--> 192 mnist_dcgan = MNIST_DCGAN()
193 timer = ElapsedTimer()
194 mnist_dcgan.train(train_steps=10000, batch_size=256, save_interval=500)

in init(self)
135
136 self.DCGAN = DCGAN()
--> 137 self.discriminator = self.DCGAN.discriminator_model()
138 self.adversarial = self.DCGAN.adversarial_model()
139 self.generator = self.DCGAN.generator()

in discriminator_model(self)
111 optimizer = RMSprop(lr=0.0002, decay=6e-8)
112 self.DM = Sequential()
--> 113 self.DM.add(self.discriminator())
114 self.DM.compile(loss='binary_crossentropy', optimizer=optimizer, metrics=['accuracy'])
115 return self.DM

in discriminator(self)
47 input_shape = (self.img_rows, self.img_cols, self.channel)
48 self.D.add(Conv2D(depth*1, 5, strides=2, input_shape=input_shape, padding='same'))
---> 49 self.D.add(LeakyReLU(alpha=0.2))
50 self.D.add(Dropout(dropout))
51

E:\Anaconda3\envs\python35\lib\site-packages\keras\models.py in add(self, layer)
490 output_shapes=[self.outputs[0]._keras_shape])
491 else:
--> 492 output_tensor = layer(self.outputs[0])
493 if isinstance(output_tensor, list):
494 raise TypeError('All layers in a Sequential model '

E:\Anaconda3\envs\python35\lib\site-packages\keras\engine\topology.py in call(self, inputs, **kwargs)
617
618 # Actually call the layer, collecting output(s), mask(s), and shape(s).
--> 619 output = self.call(inputs, **kwargs)
620 output_mask = self.compute_mask(inputs, previous_mask)
621

E:\Anaconda3\envs\python35\lib\site-packages\keras\layers\advanced_activations.py in call(self, inputs)
44
45 def call(self, inputs):
---> 46 return K.relu(inputs, alpha=self.alpha)
47
48 def get_config(self):

E:\Anaconda3\envs\python35\lib\site-packages\keras\backend\tensorflow_backend.py in relu(x, alpha, max_value)
2919 """
2920 if alpha != 0.:
-> 2921 x = tf.nn.leaky_relu(x, alpha)
2922 else:
2923 x = tf.nn.relu(x)

generate time series with gan

Hello
I want to generate fake time series using Gan's networks, but I can't use your network. I wanted you to help me if possible. Thankful

Should the discriminator's parameter be frozen during training adversarial model?

Hi,
I have a question as the title when I was studying DCGAN.

I found some other DCGAN examples of keras and it seems they will set the discriminator's parameter non-trainable during training adversarial.
Then resume it to trainable once training only discriminator model again.

But it seems in your DCGAN code doesn't do the work.
(that means setting trainable=False and recompile the model)
Is that a bug or did I misunderstand the training process of DCGAN?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.