Skip to content

Instantly share code, notes, and snippets.

View talhaanwarch's full-sized avatar
✏️
learning

Talha Anwar talhaanwarch

✏️
learning
View GitHub Profile
@talhaanwarch
talhaanwarch / gist:fef287d327df7c12bfef91eb95bc6393
Created April 23, 2023 04:13
5 Steps to Install PyTorch 2.0 and Tensorflow 2.12 on Ubuntu 22.04 with CUDA and cuDNN
Step1:
sudo apt update
sudo apt install build-essential
sudo apt-get install manpages-dev
sudo apt install gcc
Step2:
sudo sh cuda_11.8.0_520.61.05_linux.run
import torchvision
import torch
import torch.nn as nn
from time import time
from torch.optim.lr_scheduler import OneCycleLR
from pytorch_lightning import seed_everything, LightningModule, Trainer
from pytorch_lightning.callbacks import EarlyStopping,ModelCheckpoint,LearningRateMonitor
from torch.utils.data.dataloader import DataLoader
@talhaanwarch
talhaanwarch / gist:13ffc9f14043ab7933899f41a8996bb5
Last active September 7, 2021 19:07
PL segmentation gist
# data link
#https://drive.google.com/file/d/1EwjJx-V-Gq7NZtfiT6LZPLGXD2HN--qT/view?usp=sharing
from glob import glob
import cv2
from PIL import Image
import os
import pandas as pd
import numpy as np
@talhaanwarch
talhaanwarch / sentence_similarity.py
Created June 12, 2021 17:00
CALCULATE SENTENCE SIMILARITY using Pretrained BERT model
# -*- coding: utf-8 -*-
"""
Created on Fri Jun 11 18:58:05 2021
# CALCULATE SENTENCE SIMILARITY
@author: TAC
"""
import torch#pytorch
from transformers import AutoTokenizer, AutoModel#for embeddings
from sklearn.metrics.pairwise import cosine_similarity#for similarity
from joblib import Parallel, delayed
import numpy as np
import time
from mne_features.feature_extraction import FeatureExtractor
feature=['mean','variance','std']
fe = FeatureExtractor(sfreq=1024, selected_funcs=feature)
def f(x):