0% found this document useful (0 votes)
2 views

Python

The document provides an overview of various programming concepts and tools related to Python, including CLI vs GUI, debugging features in VS Code, and the structure of neural networks. It discusses Python's execution model, the importance of linters, and the use of virtual environments for dependency management. Additionally, it covers concepts like fine-tuning models, types of neurons, and the workings of LSTM in handling sequential data.

Uploaded by

aliesiere42
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Python

The document provides an overview of various programming concepts and tools related to Python, including CLI vs GUI, debugging features in VS Code, and the structure of neural networks. It discusses Python's execution model, the importance of linters, and the use of virtual environments for dependency management. Additionally, it covers concepts like fine-tuning models, types of neurons, and the workings of LSTM in handling sequential data.

Uploaded by

aliesiere42
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

🖥️CLI vs GUI

 CLI (Command Line Interface): Text-based, uses commands (e.g., terminal,


PowerShell).
 GUI (Graphical User Interface): Visual interface with buttons and windows (e.g., VS
Code, PyCharm).

🐞 Python Debugger

 Helps pause execution, step through code, inspect variables, and find bugs.
 Built-in in VS Code with useful sections like:
o Variables: Shows current variable values.
o Call Stack: Shows current function call hierarchy.
o Watch: Lets you monitor specific expressions or variables in real time.
o Breakpoints: Pauses execution at specific lines.
o Debug Console: Run Python expressions live while paused.

🧠 Call Stack in Python

 Managed by CPython (the default Python interpreter).


 Executes code line-by-line in order.
 No hoisting: You must define functions before calling them.
 Function calls are pushed onto the call stack and popped off after execution.

🛠️VS Code Debugger Highlights

 Watch section: Add variables or expressions to monitor their values live.


 Debug Console: Test or update variables, call functions at runtime.
 Breakpoints: Control where execution stops to examine program state.

💡 Live Coding Features

 During a paused debug session:


o You can call functions or change variable values in the Debug Console.
o Great for testing what-if scenarios or fixing small bugs without restarting.
How Python code is executed?

What are Linters?


Linters are programs that advise about code quality by displaying warnings and errors.
They can detect your Python code mistakes, notice invalid code patterns and find
elements that do not follow your conventions. Python linters have a number of
advantages, such as:

Is python case sensitive? Yes python is case sensitive.

JS Primitive Data Types :


 STRINGS

Formatted String in Python (Template strings of JS):


Formatted string are exactly the same thing as template string in java script.
Strings in Python:
Conditional Statements:

Ternary Operator:

Logical Operators:

Short Circuiting Logical operators:


Python would stop if it find the first “Truthy” value in case of OR or a “falsy” value in case of AND
For loop:

For else Loop:

Nested For loops:

While loop:

Functions in Python:
By default all python functions implicitly return “none” which is a special constant that
represents the absence of a value, and is a falsy value.
Keyword Arguments:
For better readability python allows us to specify the arguments passed to a function by explicitly
specifying the name of the parameter along with its value, the order doesn’t matter as long as we
specify the parameters.

Default Value parameters:


We specify the default value of a parameter in the function definition.

PIP
Pip is standard python package manager, used to install and manage and software packages.

Pip looks it up in the Python Package Index (PyPI), which is like a giant library of Python packages.
Python Virtual Environments:
Python virtual environments are isolated directories that contain a specific python interpreter and its
packages, allowing you to manage dependencies independently for different projects and to prevent
conflicts.

 Each virtual environment is separate from global python environment.


 We can install project specific libraries to that environment
 A virtual environment is essentially a copy of the python interpreter and its site packages.

Creating Environment:

Activating the Environment:

Installing Libraries to our environment:

To deactivate the environment: just put deactivate.

Solving Dependency Issue:


We can do the following command to save all dependencies to a requirement file, so that we don’t run
into dependency issues.

And then do the following to install every single dependency.


Training Your custom model:

Image resizing while training on a dataset:

Data.yml: It shows what classes does the data set have


Labels overview while training our custom model:
What is fine tuning: The fine-tuning process typically involves taking a pre-trained YOLOv8 model,
which has been trained on a large and diverse dataset, and fine-tuning it on a smaller, domain-specific
dataset.

Underfitting: The model is too simple and fails to learn the underlying patterns in the data, this would
happen if our data set is small or we didn’t run it for enough epochs.

Overfitting: The model is too complex, and learns even the irrelevant noise along with the pattern, in
turn memorizing the data set instead of learning from it. Therefore is good on test data but bad on new
data. Perhaps we ran it for too many epochs.

Neural networks: Algorithm structure is inspired by the human brain.

Structure of Nerual networks:

1. Input layer: Fixed size layer, so if we have an image of 784px, each pixel is fed to the neurons of
the input layer
2. Connection Channels: Neurons of one layer are connected to the other using channel and each
of that channel is assigned a numerical value call weight, each of this weight is multiplied to the
input and is sent to the next neuron.

3. Hidden Layer: Each neuron in the hidden layer receives the output from all the neurons in the
input layer, now each of this neuron in the first layer has a variable called the bias associated
with it, the input from previous layer and bias is passed as parameters to the activation function
which will determine if the neuron should be activated to pass its output to the next layer. Only
activated neurons can transfer data to the next layer.

What happens during training:

During training actual values are also transimted to the neural network, for every output it
compares its own output with the actual value, and adjusts it weight accordingly to match better
with the expected output.

Back propagation: The information of how offset our own result was from the expected result is fed
back from the output layer all the way to the input layer going through hidden layers and all that.
The weights are adjusted and the whole process is repeated for a certain epochs to train the model
Types of Neurons:

 Multilayer Perceptron: Perceptron(single neuron) so a multilayer perceptron is a multi


layer neural network as in the above image.
 Recurrent Neural Networks: An RNN is a type of neural network that's specially
designed to handle sequential data — data where order matters. In a regular neural
network (like an MLP), inputs are independent of each other. But in many real-life
problems, inputs are related over time. Vanishing Gradient Problem:
 LSTM( Long short tem Memory): it’s a type of RNN, it solves the vanishing gradient
problem of RNN by adding an internal state to and RNN node, so along with input from
previous and current node it also receives the state information.

o Forget Gate: says what sort of state information stored in the state can be
forgotten, no longer needed.
o Input Gate: what new information should be added to the working state.
o Output gate: of all the information stored in the state which part of it should be
outputted. Each gate is assigned 0, 1 indicating if they are often or close.

We use lstm for machine transaltion, and chat bots.

You might also like