Skip to content
View deependujha's full-sized avatar
Block or Report

Block or report deependujha

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
deependujha/README.md

Hi there 👋 I'm Deep 🤠


Deependu Jha profile views


Codes I use often but don't remember:

  1. PyTorch device (MPS, CUDA, CPU)
import torch

# Get cpu, gpu or mps device for training.
device = (
    "cuda"
    if torch.cuda.is_available()
    else "mps"
    if torch.backends.mps.is_available()
    else "cpu"
)
print(f"Using {device=}")

  1. Matplotlib multiple plot
import numpy as np
import matplotlib.pyplot as plt

x = np.arange(1,11)
y = 3*x+2
z = x**2+5

# --------------------------------------------

fig, axs = plt.subplots(nrows=2, ncols=2, figsize=(12, 4))
axs[0][0].plot(x, y)
axs[0][1].plot(x, z)
axs[1][0].plot(x, z)
axs[1][1].plot(x, y)

plt.show()

  1. Argument Parser in python
import os
from argparse import ArgumentParser

if __name__ == "__main__":
    # enable CLI commands
    parser = ArgumentParser()
    parser.add_argument('--data', type=str,
                        default=os.getcwd() + '/example_dataset')
    parser.add_argument('--max_steps', type=int, default=100)
    parser.add_argument('--lr', type=float, default=1e-3)
    parser.add_argument('--batch_size', type=int, default=2)
    args = parser.parse_args()
    
    print(f"{args=}")
    print(f"batch size: {args.batch_size}")

Pinned

  1. Nano-GPT Nano-GPT Public

    Jupyter Notebook 3

  2. PyTorchVision PyTorchVision Public

    Jupyter Notebook 1

  3. PyTorchista PyTorchista Public

    Jupyter Notebook 1

  4. Optimizers_In_Machine_n_Deep_Learning Optimizers_In_Machine_n_Deep_Learning Public

    1

  5. constitution-gpt constitution-gpt Public

    Jupyter Notebook 4

  6. drift-ethindia drift-ethindia Public

    JavaScript 1 4