Skip to content

Instantly share code, notes, and snippets.

View imflash217's full-sized avatar
🔭
महाजनो येन गतः स पन्थाः ॥

Vinay Kumar imflash217

🔭
महाजनो येन गतः स पन्थाः ॥
  • United States
  • 04:53 (UTC -04:00)
View GitHub Profile
@RuolinZheng08
RuolinZheng08 / backtracking_template.py
Last active August 12, 2026 06:56
[Algo] Backtracking Template & N-Queens Solution
def is_valid_state(state):
# check if it is a valid solution
return True
def get_candidates(state):
return []
def search(state, solutions):
if is_valid_state(state):
solutions.append(state.copy())
@EdisonLeeeee
EdisonLeeeee / pytorch_l2_normalize.py
Last active August 22, 2022 10:53
PyTorch equivalence for tf.nn.l2_normalize
import torch
import tensorflow as tf
########## PyTorch Version 1 ################
x = torch.randn(5, 6)
norm_th = x/torch.norm(x, p=2, dim=1, keepdim=True)
norm_th[torch.isnan(norm_th)] = 0 # to avoid nan
########## PyTorch Version 2 ################
norm_th = torch.nn.functional.normalize(x, p=2, dim=1)