Skip to content

Instantly share code, notes, and snippets.

View ShairozS's full-sized avatar

Shairoz Sohail ShairozS

View GitHub Profile
@ShairozS
ShairozS / gist:3af4cddb2a6566cf623b62e110445a80
Last active February 4, 2025 22:13
Test_3sat_solvers.py
import random
import time
import itertools
import numpy as np
import os
import numpy as np
import json
from tqdm import tqdm
from pysat.solvers import Glucose42, Minicard, Lingeling, Cadical153, Minisat22,MapleChrono, Mergesat3
@ShairozS
ShairozS / linear_pair.ipynb
Created December 19, 2021 03:05
Linear probe on Pairwise-Contrastive Model
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ShairozS
ShairozS / distances_ntxent.ipynb
Created December 6, 2021 01:25
Inspecting Embedding Distances
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ShairozS
ShairozS / h_imagefolder.py
Last active December 6, 2021 00:52
Hierarchical ImageFolder Pytorch
import matplotlib.pyplot as plt
from PIL import Image
from torch.utils.data import Dataset
from torchvision import transforms
import os
class HierarchicalImageFolder(Dataset):
def __init__(self, root, hlevel=2, ftype='.jpg', transforms=None):
'''
@ShairozS
ShairozS / train_mnist_xent.ipynb
Created December 5, 2021 21:38
Training MNIST with Cross Entropy
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ShairozS
ShairozS / train_mnist_ntxent.ipynb
Created November 26, 2021 04:16
Training MNIST with NT-Xent Loss
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ShairozS
ShairozS / losses.py
Created November 26, 2021 03:51
Contrastive triplet, pairs and Nt-Xent losses
import torch
import numpy as np
import torch.nn.functional as F
def form_triplets(inA, inB):
'''
Form triplets from two tensors of embeddings. It is assumed that the embeddings at corresponding batch positions are similar
and all other batch positions are dissimilar
@ShairozS
ShairozS / train_mnist_triplet.ipynb
Created November 25, 2021 23:35
Train MNIST with contrastive triplet loss
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ShairozS
ShairozS / losses.py
Created November 25, 2021 23:23
Contrastive pair loss and triplet loss
import torch
import numpy as np
import torch.nn.functional as F
def form_triplets(inA, inB):
'''
Form triplets from two tensors of embeddings. It is assumed that the embeddings at corresponding batch positions are similar
and all other batch positions are dissimilar
@ShairozS
ShairozS / train_mnist_pair.ipynb
Created November 25, 2021 23:11
Training a Pytorch contrastive backbone with pairwise contrastive loss
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.