Skip to content

Instantly share code, notes, and snippets.

View sandeepnmenon's full-sized avatar

Sandeep Menon sandeepnmenon

View GitHub Profile
@sandeepnmenon
sandeepnmenon / Time complexity and Basic Algorithms
Last active December 20, 2015 17:26
WEB CLUB WInter Mentorship : NOtes
big oh and time complecity : http://bigocheatsheet.com/
: http://www.studytonight.com/data-structures/time-complexity-of-algorithms
: http://web.mit.edu/16.070/www/lecture/big_o.pdf
Prime Check: http://ideone.com/Sp58lL
searcing algorithms :
binary search :
@sandeepnmenon
sandeepnmenon / cnn.py
Last active June 16, 2020 23:25
Keras CNN with skip connections and gates
def get_cnn_architecture(weights_path=None):
input_img = Input(shape=(64,64,3)) # adapt this if using `channels_first` image data format
x1 = Conv2D(64, (3, 3), activation='relu', padding='same')(input_img)
gateFactor = Input(tensor = K.variable([0.3]))
fractionG = Multiply()([x1,gateFactor])
complement = Lambda(lambda x: x[0] - x[1])([x1,fractionG])
x = MaxPooling2D((2, 2), padding='same')(fractionG)
@sandeepnmenon
sandeepnmenon / gated_DAE.py
Last active March 13, 2019 20:21
Gated autoencoder model
def get_gated_connections(gatePercentageFactor,inputLayer):
gateFactor = Input(tensor = K.variable([gatePercentageFactor]))
fractionG = Lambda(lambda x: x[0]*x[1])([inputLayer,gateFactor])
complement = Lambda(lambda x: x[0] - x[1])([inputLayer,fractionG])
return gateFactor,fractionG,complement
#x is conv layer
#y is de-conv layer
#gf is gating factor
@sandeepnmenon
sandeepnmenon / bhavcopy.ipynb
Created February 23, 2020 17:39
Download Bhavcopy files
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sandeepnmenon
sandeepnmenon / prime_generator.py
Last active August 11, 2021 07:09
Prime number generator using lazy Sieve of Eratosthenes
def natural_number_generator(n):
yield n
yield from natural_number_generator(n+1)
def sieve_of_eratosthenes(number_list):
next_prime = next(number_list)
yield next_prime
yield from sieve_of_eratosthenes(i for i in number_list if i%next_prime != 0)
if __name__ == '__main__':
@sandeepnmenon
sandeepnmenon / sudoku_generator.py
Created August 11, 2021 07:29
Sudoku Sequence Generator
import numpy as np
# Generator for all possible sudoku grids
def sudoku_generator(sudoku):
for y in range(9):
for x in range(9):
# If cell not filled
if sudoku[y][x] == 0:
# Check if any number in the range is valid in the empty cell
for n in range(1,10):
@sandeepnmenon
sandeepnmenon / switch_loop_magic.cpp
Created September 21, 2022 04:37
Duff's device
#include <iostream>
using namespace std;
int main()
{
int count = 7;
switch (
count % 5)
{
@sandeepnmenon
sandeepnmenon / optimus.py
Last active November 29, 2022 03:43
Optimus fitting
from scipy.optimize import nnls
from scipy.optimize import curve_fit
import math
def optimus_fitting(df):
"""
This function takes in a csv file and returns b0,b1 and b2 fitting the model
l = 1/(b0*k + b1) + b2
l is the training loss
k is the number of iterations