Skip to content

Instantly share code, notes, and snippets.

Avatar

Vishal Goklani vgoklani

  • New York, NY
View GitHub Profile
View f1_maximization.pyx
cimport cython
import numpy as np
cimport numpy as np
from sklearn.metrics import f1_score
@cython.boundscheck(False)
@cython.wraparound(False)
def f1_opt(np.ndarray[long, ndim=1] label, np.ndarray[double, ndim=1] preds):
@vgoklani
vgoklani / custom_layers.md
Created Jul 13, 2019
Blog - Custom layers in Keras
View custom_layers.md

Building custom layers in Keras

About Keras

Keras is currently one of the most commonly used deep learning libraries today. And part of the reason why it's so popular is its API. Keras was built as a high-level API for other deep learning libraries ie Keras as such does not perform low-level tensor operations, instead provides an interface to its backend which are built for such operations. This allows Keras to abstract a lot of the underlying details and allows the programmer to concentrate on the architecture of the model. Currently Keras supports Tensorflow, Theano and CNTK as its backends.

Let's see what I mean. Tensorflow is one of the backends used by Keras. Here's the code for MNIST classification in TensorFlow and Keras. Both models are nearly identical and applies to the same problem. But if you compare the codes you g

@vgoklani
vgoklani / crypto_news.json
Created Apr 5, 2019 — forked from stungeye/crypto_news.json
News Site RSS Feeds
View crypto_news.json
[
{
"url": "http://money.cnn.com",
"rss": "http://rss.cnn.com/rss/money_topstories.rss"
},
{
"url": "http://thehill.com",
"rss": "http://thehill.com/rss/syndicator/19110"
},
{
@vgoklani
vgoklani / stats.py
Created Feb 1, 2019 — forked from impshum/stats.py
Get mongodb stats using python with pymongo
View stats.py
from pymongo import MongoClient
try:
client = MongoClient('localhost')
db = client.searchfollow
except:
print("Could not connect to MongoDB")
call = db.command("dbstats")
View Pytorch Wavenet.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vgoklani
vgoklani / Pytorch RNN.ipynb
Created Nov 7, 2018 — forked from lirnli/Pytorch RNN.ipynb
Pytorch RNN examples
View Pytorch RNN.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vgoklani
vgoklani / Simple Dilation Network.ipynb
Created Nov 7, 2018 — forked from lirnli/Simple Dilation Network.ipynb
Simple Dilation Network to generate sine waves
View Simple Dilation Network.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vgoklani
vgoklani / Zoom.ipynb
Created Nov 7, 2018 — forked from lirnli/Zoom.ipynb
Attention layer in neural networks
View Zoom.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@vgoklani
vgoklani / pad_packed_demo.py
Created Oct 23, 2018 — forked from Tushar-N/pad_packed_demo.py
How to use pad_packed_sequence in pytorch
View pad_packed_demo.py
import torch
import torch.nn as nn
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
seqs = ['gigantic_string','tiny_str','medium_str']
# make <pad> idx 0
vocab = ['<pad>'] + sorted(set(''.join(seqs)))
# make model
@vgoklani
vgoklani / parser.py
Last active Sep 5, 2018 — forked from pieceofsummer/parser.py
Google Wifi diagnostic report parser
View parser.py
#!/usr/bin/python
import os, sys, gzip
from StringIO import StringIO
from datetime import datetime
def readByte(f):
return ord(f.read(1))
def readInt(f):
l = 0
You can’t perform that action at this time.