Skip to content

Instantly share code, notes, and snippets.

View itsNisarg's full-sized avatar
:atom:
Learning 'n' Innovating

Nisarg itsNisarg

:atom:
Learning 'n' Innovating
View GitHub Profile
@itsNisarg
itsNisarg / positional_encoding.py
Created June 1, 2026 12:25
Exploring positional embeddings
import torch
import matplotlib.pyplot as plt
# ── Environment diagnostics ───────────────────────────────────────────────────
# Print the runtime environment so results are reproducible and hardware-aware.
print(f"PyTorch version: {torch.__version__}")
print(f"CUDA available: {torch.cuda.is_available()}")
print(f"MPS available: {torch.backends.mps.is_available()}")
print(f"MPS built: {torch.backends.mps.is_built()}")
@itsNisarg
itsNisarg / ctxmng.py
Last active June 20, 2022 14:10
An indent manager using context management and with keyword.
class Indent():
def __init__(self):
self.level = 0
def __enter__(self):
self.level+=1
return self
def __exit__(self, *exc):
self.level -= 1
/**
*@file
*@author Nisarg Suthar(nisargsuthar0@gmail.com)
*@brief
*@version 0.1
*@date
*@copyright Copyright (c) 2021
*/
int start_up() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
return 0;
}
int static r = start_up();
#define endl '\n';