Skip to content

Instantly share code, notes, and snippets.

View bikcrum's full-sized avatar
💭
I will respond anyway.

Bikram Pandit bikcrum

💭
I will respond anyway.
View GitHub Profile
@bikcrum
bikcrum / convNd.py
Created February 21, 2024 21:44
Implementation of ND convolution using numpy
import numpy as np
import torch
from torch import nn
import tqdm
def convNd(in_channels=1, out_channels=1, kernel_size=2, stride=1, padding=1, weight=None, bias=None):
# These are filters or kernels
if weight is None:
weight = np.ones((out_channels, in_channels, *kernel_size))
# O,C,*kernel_size
@bikcrum
bikcrum / policy_iteration_compact_numpy.py
Created January 31, 2024 00:20
Policy iteration using numpy broadcasting
# env [MDP environment]
# nS [state_dim]
# nA [action_dim]
# env.TransitProb [state_dim x action_dim x state_dim]
# env.TransitReward [state_dim x action_dim], Note: It maybe in shape [state_dim x action_dim x state_dim]. In such
# case no need to expand dim. It can also be in the same [state_dim], then it is required to expand dim twice accordingly
@bikcrum
bikcrum / value_iteration_compact_numpy.py
Created January 31, 2024 00:18
Value iteration using numpy broadcasting
# Value iteration compact
# env [MDP environment]
# nS [state_dim]
# env.TransitProb [state_dim x action_dim x state_dim]
# env.TransitReward [state_dim x action_dim], Note: It maybe in shape [state_dim x action_dim x state_dim]. In such
@bikcrum
bikcrum / transformer.py
Created May 15, 2023 09:54
Transformer that returns attentions maps
import copy
from typing import Optional, Any, Union, Callable
import torch
from torch import Tensor
from .. import functional as F
from .module import Module
from .activation import MultiheadAttention
from .container import ModuleList
from ..init import xavier_uniform_
@bikcrum
bikcrum / port-forwarding.txt
Created October 30, 2022 05:34
Jupyter port forwarding from HPC node to a local machine [Oregon State University]
1. I set this on my local machine and flip
`alias port_map='f(){ ssh -N -L "$2":localhost:"$2" panditb@"$1".engr.oregonstate.edu; unset -f f; }; f'`
2. Enter into flip3 (use same node to re-establish connection to HPC if lost, eg '3' here)
`ssh panditb@flip3.engr.oregonstate.edu`
3. Enter HPC and whatever node thereafter (For example if you connect to cn-gpu5, hostname will be gpu5).
`ssh panditb@compute-{hostname}.hpc.engr.oregonstate.edu`
4. I start the jupyter on node
name: ml
channels:
- apple
- defaults
- conda-forge
dependencies:
- anyio=3.5.0
- aom=3.3.0
- appdirs=1.4.4
- appnope=0.1.2

Setting up miniforge for TensorFlow support

  1. Download [Miniforge3-MacOSX-arm64.sh][1]
  2. Run the file using the following command:-
    • ./Miniforge3-MacOSX-arm64.sh
  3. It will download miniforge in the current directory. Now you have to activate it. Use the following command to do so.
    • source miniforge3/bin/activate
  4. You should see (conda) is prepended in your command line. To make sure it is activated during terminal start-up. Use the following command.
    • conda init
    • or if you are using zsh, conda init zsh
@bikcrum
bikcrum / hello_world.js
Created October 19, 2021 04:51
Hey! I've been edited!
conosle.log('Hello World');
@bikcrum
bikcrum / hello_world.js
Created October 19, 2021 04:51
test gist
conosle.log('Hello World');
@bikcrum
bikcrum / hello_world.txt
Created October 19, 2021 04:11
Patched Hello World
Run 'node hello_world.js' to print Hello World