Skip to content

Instantly share code, notes, and snippets.

View rahuldshetty's full-sized avatar
🏠
Code is where the heart is.

Rahul D Shetty rahuldshetty

🏠
Code is where the heart is.
View GitHub Profile
@rahuldshetty
rahuldshetty / label_encoder.py
Created January 28, 2020 06:17
A Label encoder implementation in python.
import pickle
class LabelEncoder:
'''
Utility function to encode labels to keys and vice versa
'''
def __init__(self,label_list):
self.label_list = list(set(label_list))
self.map_key = {index:self.label_list[index] for index in range(len(self.label_list))}
self.unmap_key = {self.map_key[idx]:idx for idx in range(len(self.label_list))}
@rahuldshetty
rahuldshetty / node.py
Created January 18, 2021 19:47
Implementation of Node Data Structure in Python3
class Node:
__left = None
__right = None
def __init__(self, value) -> None:
super().__init__()
self.__value = value
@property
def value(self):
@rahuldshetty
rahuldshetty / bst.py
Created January 18, 2021 19:55
Python3 Implementation for Binary Search Tree with Insert, Delete, Search, Printing IN,PRE,POST Order.
from node import Node
class BST:
__root = None
def insert(self, value):
def _insert(root, value):
if root is None:
@rahuldshetty
rahuldshetty / bst-example.py
Created January 18, 2021 19:57
Example Code for testing out Binary Search Tree Python3 Implementation.
from bst import BST
bst = BST()
values = [2,1,5,44,15]
for x in values:
bst.insert(x)
bst.inorder()
@rahuldshetty
rahuldshetty / processing.py
Created February 8, 2021 17:29
processing.py
import re
import numpy as np
c2i = {' ': 0, 'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15, 'p': 16, 'q': 17, 'r': 18, 's': 19, 't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26}
max_len = 10
def process_text(name):
name = name.lower()
name = re.sub("[^a-z ]", "", name)
name = " ".join([x for x in name.split() if len(x)!=1])
@rahuldshetty
rahuldshetty / model.py
Created February 8, 2021 17:30
model.py
import tensorflow as tf
model = tf.keras.Sequential([
tf.keras.layers.Embedding(len(char2id) + 1, 100, input_length=max_len),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(512, activation='relu'),
tf.keras.layers.Dense(1, activation='sigmoid')
])
model.compile(loss='binary_crossentropy', optimizer='rmsprop', metrics=['accuracy'])
@rahuldshetty
rahuldshetty / App.js
Created February 8, 2021 17:46
App.js
import logo from './logo.svg';
import './App.css';
import {useState, useEffect} from "react";
import * as tf from '@tensorflow/tfjs';
function App() {
const [result, setResult] = useState();
const [model,setModel] = useState();
const [prob, setProb] = useState();
const c2i = {" ": 0, "a": 1, "b": 2, "c": 3, "d": 4, "e": 5, "f": 6, "g": 7, "h": 8, "i": 9, "j": 10, "k": 11, "l": 12, "m": 13, "n": 14, "o": 15, "p": 16, "q": 17, "r": 18, "s": 19, "t": 20, "u": 21, "v": 22, "w": 23, "x": 24, "y": 25, "z": 26};
@rahuldshetty
rahuldshetty / LLM.md
Created June 20, 2023 18:50 — forked from rain-1/LLM.md
LLM Introduction: Learn Language Models

Purpose

Bootstrap knowledge of LLMs ASAP. With a bias/focus to GPT.

Avoid being a link dump. Try to provide only valuable well tuned information.

Prelude

Neural network links before starting with transformers.