Skip to content

Instantly share code, notes, and snippets.

@Infinitusvoid
Infinitusvoid / change_extension.bat
Created April 9, 2024 17:35
Bat : bash script that changes the files extension for all files in a folder to specefied one
@echo off
setlocal enabledelayedexpansion
rem Check if user provided the old extension and new extension
if "%~2"=="" (
echo Usage: %~nx0 old_extension new_extension
exit /b 1
)
set "old_extension=%~1"
@Infinitusvoid
Infinitusvoid / readme.md
Last active January 3, 2024 18:16
Batch with Magick : How to converet webp animated image into image frames
@Infinitusvoid
Infinitusvoid / note.txt
Created October 19, 2023 12:06
Visual studio : How to enable disable white space ?
you press ctrl + w, r
@Infinitusvoid
Infinitusvoid / code.txt
Created September 4, 2023 12:30
Python : How to start a basic http server ?
python -m http.server 8080
@Infinitusvoid
Infinitusvoid / code.py
Created August 30, 2023 15:43
Python : How to get the version of python ?
import sys
print("Python version :", sys.version)
print(" Version information : ", sys.version_info)
@Infinitusvoid
Infinitusvoid / code.py
Created August 24, 2023 22:30
Jupyter Notebook : How in jupiter notebook get the nvidea graphic card information ?
!nvidia-smi
@Infinitusvoid
Infinitusvoid / code.py
Created August 24, 2023 22:16
PyTorch : How to seed rand, custom seed ?
import torch
# Set the random seed
RANDOM_SEED = 42
torch.manual_seed(RANDOM_SEED)
random_tensor_A = torch.rand(3, 4)
print(random_tensor_A)
torch.manual_seed(RANDOM_SEED)
@Infinitusvoid
Infinitusvoid / gist:76ec68a674e5aaf6e417523d5e1872d7
Created August 24, 2023 22:07
PyTorch : How to check if cuda is available ?
import torch
print(torch.cuda.is_available())
@Infinitusvoid
Infinitusvoid / code.py
Created August 24, 2023 22:05
PyTorch : How to get to get the PyTorch versions ?
import torch
print(torch.__version__)
@Infinitusvoid
Infinitusvoid / code.py
Created August 24, 2023 20:55
PyTorch : How to convert tensor to numpy array, and back ?
import numpy as np
import torch
# Tensor to NumPy array
tensor = torch.ones(7)
numpy_tensor = tensor.numpy()
tensor, numpy_tensor
#What about going back
tensor = torch.from_numpy(array) # warning: when converting from numpy -> pytorch, pytorch reflects numpy's default datatype of float64 unless specefied otherwise