Skip to content

Instantly share code, notes, and snippets.

View akkefa's full-sized avatar
💻
Grit

Ikram Ali akkefa

💻
Grit
View GitHub Profile
@akkefa
akkefa / tmux-cheatsheet.markdown
Created January 30, 2019 13:10 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@akkefa
akkefa / Linux disk Management commands
Last active April 29, 2022 12:30
All commands related to disk management
## Check space on specfic directory
du -h --max-depth=0 /u/iali
du -h --max-depth=1 /u/iali
@akkefa
akkefa / Automate your Python project with Makefile
Created June 17, 2022 18:17
Automate your Python project with Makefile
coverage: ## Run tests with coverage
coverage erase
coverage run --include=podsearch/* -m pytest -ra
coverage report -m
deps: ## Install dependencies
pip install black coverage flake8 mypy pylint pytest tox
lint: ## Lint and static-check
flake8 podsearch
@akkefa
akkefa / gist:64ddc3fc8d74406f814ca348be4a8725
Created December 20, 2022 07:04
Pytorch Dataloader Example
import torch
from torch.utils.data import DataLoader, TensorDataset
# Define the dataset
X = torch.Tensor([[1, 2], [3, 4], [5, 6], [7, 8]])
y = torch.Tensor([0, 1, 0, 1])
dataset = TensorDataset(X, y)
# Create the dataloader
dataloader = DataLoader(dataset, batch_size=2, shuffle=True)
@akkefa
akkefa / binary_tensor.py
Created December 20, 2022 19:20
Threshold a tensor into binary values using pytorch (torch.where)
import torch
# Create a tensor with values between 0 and 1
tensor = torch.rand(3, 3)
# Set a threshold value
threshold = 0.5
# Use torch.where to threshold the tensor
binary_tensor = torch.where(tensor > threshold, torch.tensor(1), torch.tensor(0))