-
This porject aimes to make a deep learning model in order to extract items from a sport video in order to detect which sport is in the video .
-
In this
Model
we will use a dataset of images classed by names, for example :{ 'Basketball': [ image_1, image_2, image_3, ... ], 'Football' : [...], 'Hockey' : [...], ... }
-
We exctract the images in order to train the
CNN
withPyTorch
. -
We will save the model and use it in video processing and in order to detect the sport playing in the video .
-
We used
Pytorch
for model creation, and tensor creations : -
We used
sklearn
for metrics and performance : -
We used
numpy
for ndarray manupilation befor transforme it totorch tensors
:
SGD
(Stochastic Gradient Descent) Optimizer:
The SGD optimizer is a widely used optimization algorithm for training machine learning models. The update step for each parameter is computed using the following formula:
with :
-
$\theta_{new}$ : is the updated value of the parameter.
-
$\theta_{old}$ : is the current value of the parameter.
-
$\alpha$ : is the learning rate hyperparameter, controlling the step size during updates. -
$\nabla\mathcal{L(x, \mathscr{C})}$ : is the gradient of the loss function with respect to the parameter. -
$\mathrm{momentum }$ : is the momentum hyperparameter, which smooths the update process and helps to accelerate convergence in certain cases. -
$\mathrm{previousUpdate}$ : is the accumulated previous update for the parameter. -
$\mathrm{weightDecay}$ : is the weight decay hyperparameter, which applies L2 regularization to the parameter to prevent overfitting.
in Python
and Pytorch
:
optimizer = optim.SGD(model.fc.parameters(), lr=0.001, momentum=0.9, weight_decay=1e-4)
CrossEntropyLoss
:
CrossEntropyLoss is a common loss function used for classification tasks. The formula for the CrossEntropyLoss is as follows:
with :
-
$x$ is the output (logits) from the last layer of the neural network for a particular input. -
$\mathscr{C}$ is the true class label of the input. -
$x_{c}$ is the input for the class$\mathscr{C}$ .