user-profile-img

Soheil Ghafurian

@soheilghafurian• May 21, 2023open-state

The Fundamentals of Autograd — PyTorch Tutorials 2.0.1+cu117 documentation

The power of autograd comes from the fact that it traces your computation dynamically at runtime

far more flexibility than frameworks that rely on static analysis of a more rigidly-structured model for computing gradients.

This is where autograd comes in: It tracks the history of every computation. Every computed tensor in your PyTorch model carries a history of its input tensors and the function used to create it. Combined with the fact that PyTorch functions meant to act on tensors each have a built-in implementation for computing their own derivatives, this greatly speeds the computation of the local derivatives needed for learning

-

The Fundamentals of Autograd — PyTorch Tutorials 2.0.1+cu117 documentationpytorch.org

user-profile-img

Soheil Ghafurian

@soheilghafurian• May 13, 2023open-state

Python import: Advanced Techniques and Tips – Real Python

Python code is organized into both modules and packages

In practice, a module usually corresponds to one .py file containing Python code.

math is part of Python’s standard library, which means that it’s always available to import when you’re running Python.

-

Python import: Advanced Techniques and Tips – Real Pythonrealpython.com

user-profile-img

Soheil Ghafurian

@soheilghafurian• May 8, 2023open-state

Using the Python zip() Function for Parallel Iteration

Returns an iterator of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables. The iterator stops when the shortest input iterable is exhausted. With a single iterable argument, it returns an iterator of 1-tuples. With no arguments, it returns an empty iterator.

You’ll unpack this definition throughout the rest of the tutorial. As you work through the code examples, you’ll see that Python zip operations work just like the physical zipper on a bag or pair of jeans. Interlocking pairs of teeth on both sides of the zipper are pulled together to close an opening. In fact, this visual analogy is perfect for understanding zip(), since the function was named after physical

Python’s zip() function is defined as zip(*iterables

-

Using the Python zip() Function for Parallel Iterationrealpython.com

user-profile-img

Soheil Ghafurian

@soheilghafurian• Mar 1, 2023open-state

Documenting Python Code: A Complete Guide

“Code is more often read than written.”

Documenting your Python code is all centered on docstrings.

Along with docstrings, Python also has the built-in function help() that prints out the objects docstring to the console.

-

Documenting Python Code: A Complete Guiderealpython.com

user-profile-img

Soheil Ghafurian

@soheilghafurian• Feb 14, 2023open-state

How diffusion models work: the math from scratch | AI Summer

Example architectures that are based on diffusion models are GLIDE, DALLE-2, Imagen, and the full open-source stable diffusion.

We will focus on the most prominent one, which is the Denoising Diffusion Probabilistic Models (DDPM) as initialized by Sohl-Dickstein et al and then proposed by Ho. et al 2020

stable diffusion

-

How diffusion models work: the math from scratch | AI Summertheaisummer.com

user-profile-img

Soheil Ghafurian

@soheilghafurian• Feb 13, 2023open-state

Scheduling recurring tasks using crontab command - Dextutor

-

Scheduling recurring tasks using crontab command - Dextutordextutor.com

user-profile-img

Soheil Ghafurian

@soheilghafurian• Feb 12, 2023open-state

CLI Options with Multiple Values - Typer

You can also declare a CLI option that takes several values of different types.

For this, use the standard Python typing.Tuple:

You can set the number of values and types to anything you want, but it has to be a fixed number of values.

-

CLI Options with Multiple Values - Typertyper.tiangolo.com

user-profile-img

Soheil Ghafurian

@soheilghafurian• Feb 12, 2023open-state

Multiple CLI Options - Typer

You can declare a CLI option that can be used multiple times, and then get all the values.

For this, use the standard Python typing.List to declare it as a list of str:

The same way, you can use other types and they will be converted by Typer to their declared type:

-

Multiple CLI Options - Typertyper.tiangolo.com

user-profile-img

Soheil Ghafurian

@soheilghafurian• Feb 11, 2023open-state

python import modules after the help option - Google Search

-

python import modules after the help option - Google Searchwww.google.com

user-profile-img

Soheil Ghafurian

@soheilghafurian• Feb 11, 2023open-state

One or Multiple Commands - Typer

Typer is smart enough to create a CLI application with that single function as the main CLI application, not as a command/subcommand:

noticed that if you create a single command, as in the first example

Notice that it doesn't show a command main, even though the function name is main.

-

One or Multiple Commands - Typertyper.tiangolo.com