Skip to content

Instantly share code, notes, and snippets.

Avatar

Bhabani mohapatras

View GitHub Profile
@mohapatras
mohapatras / repo_push_github
Created Feb 15, 2020
Push local data to github using git.
View repo_push_github
# Create a new repository on the command line
touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/mohapatras/python.git
git push -u origin master
# Push an existing repository from the command line
@mohapatras
mohapatras / quickSort.py
Created Jun 21, 2018
Quick Sort implementation in python 3 with last element as pivot.
View quickSort.py
def partition(A, start, end):
pivot = A[end]
pIndex = start
for i in range(start, len(A)):
if A[i] < pivot:
A[i], A[pIndex] = A[pIndex], A[i]
pIndex += 1
A[pIndex], A[end] = A[end], A[pIndex]
@mohapatras
mohapatras / gpu_tf_keras_memory_limit.py
Last active Apr 4, 2018
Assign before doing any keras operation.
View gpu_tf_keras_memory_limit.py
# keras example imports
from keras.models import load_model
## extra imports to set GPU options
import tensorflow as tf
from keras import backend as k
###################################
# TensorFlow wizardry
config = tf.ConfigProto()
@mohapatras
mohapatras / resnet.py
Last active Jan 4, 2020
# Resnet50 with grayscale images.
View resnet.py
import numpy as np
import warnings
import os
import tensorflow as tf
from keras.layers import Input
from keras import layers
from keras.layers import Dense
from keras.layers import Activation
from keras.layers import Flatten
@mohapatras
mohapatras / cuda_cudnn_version.sh
Created Mar 23, 2018
check_cuda and cudnn versions ubuntu.
View cuda_cudnn_version.sh
# CUDA version
nvcc --version
which nvcc
# CudaNN version
# Use the output of which nvcc to locate your cuda
cat /usr/include/x86_64-linux-gnu/cudnn_v*.h | grep CUDNN_MAJOR -A 2
View mem_keras_tf.py
# memory growth options for keras and tensorflow.
from keras import backend as K
cfg = K.tf.ConfigProto()
cfg.gpu_options.allow_growth = True
K.set_session(K.tf.Session(config=cfg))
@mohapatras
mohapatras / plank_notes
Created Sep 14, 2017 — forked from erogol/plank_notes
Kaggle Plankton Classification winner's approach notes
View plank_notes
FROM: http://benanne.github.io/2015/03/17/plankton.html
Meta-Tricks:
- Use %10 for validation with STRATIFIED SAMPLING (my mistake)
- Cyclic Pooling
- Leaky ReLU = max(x, a*x) learned a
- reduces overfitting with a ~= 1/3
- Orthogonal initialization http://arxiv.org/pdf/1312.6120v3.pdf
- Use larger weight decay for larger models since otherwise some layers might diverge
@mohapatras
mohapatras / keras_tensor_export.py
Last active Jun 12, 2017
Found in a comment by user @tspthomas.
View keras_tensor_export.py
'''
I managed to export a Keras model for Tensorflow Serving (not sure whether it is the official way to do
this). My first trial prior to creating my custom model was to use a trained model available on
Keras such as VGG19.
Here is how I did (I put in separate boxes to help understanding and because I use Jupyter :)):
'''
#Creating the model
import keras.backend as K
@mohapatras
mohapatras / 0_reuse_code.js
Created Jun 11, 2017
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View pins.json
[{
"name": "Plan B",
"latitude": 12.9716,
"longitude": 77.5946
}, {
"name": "Locals",
"latitude": 12.933290,
"longitude": 77.622964
}, {
"name": "Toit",