Skip to content

Instantly share code, notes, and snippets.

View singhay's full-sized avatar
🐢
Exciting times!

Ayush Singh singhay

🐢
Exciting times!
View GitHub Profile
@hlzz
hlzz / gist:ba6da6e692beceb4da8b4d5387a8eacc
Created February 28, 2018 09:03
Generate sprite images for tensorboard
#!/usr/bin/python
from PIL import Image
import math
test_image_list = '/home/tianwei/Data/sfm_data/test_image_list' # path to the image list
with open(test_image_list, 'r') as f:
test_images = f.readlines()
test_images = map(str.strip, test_images)
@philmerrell
philmerrell / audio.service.ts
Created November 20, 2017 21:10
Angular audio service class
import { Injectable } from '@angular/core';
import { Observable, BehaviorSubject } from 'rxjs/Rx';
@Injectable()
export class AudioService {
public audio: HTMLAudioElement;
public timeElapsed: BehaviorSubject<string> = new BehaviorSubject('00:00');
public timeRemaining: BehaviorSubject<string> = new BehaviorSubject('-00:00');
public percentElapsed: BehaviorSubject<number> = new BehaviorSubject(0);
@ululh
ululh / LDApredict.py
Last active February 1, 2023 09:32
LDA (Latent Dirichlet Allocation) predicting with python scikit-learn
# derived from http://scikit-learn.org/stable/auto_examples/applications/topics_extraction_with_nmf_lda.html
# explanations are located there : https://www.linkedin.com/pulse/dissociating-training-predicting-latent-dirichlet-lucien-tardres
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.decomposition import LatentDirichletAllocation
import pickle
# create a blank model
lda = LatentDirichletAllocation()
@ilblackdragon
ilblackdragon / seq2seq.py
Last active May 22, 2022 21:42
Example of Seq2Seq with Attention using all the latest APIs
import logging
import numpy as np
import tensorflow as tf
from tensorflow.contrib import layers
GO_TOKEN = 0
END_TOKEN = 1
UNK_TOKEN = 2
@joshuatvernon
joshuatvernon / functional-quicksort.py
Last active September 5, 2017 03:07
A functional quicksort
from random import randint
# Quicksort with starting index as pivot
def qsort(items):
if len(items) < 2:
return items
pivot = items[0]
left = list(filter(lambda x: x <= pivot, items[1:]))
right = list(filter(lambda x: x > pivot, items[1:]))
return qsort(left) + [pivot] + qsort(right)
# coding: utf-8
# Imports
import os
import cPickle
import numpy as np
import theano
import theano.tensor as T
@aronwc
aronwc / lda.py
Last active April 30, 2024 06:54
Example using GenSim's LDA and sklearn
""" Example using GenSim's LDA and sklearn. """
import numpy as np
from gensim import matutils
from gensim.models.ldamodel import LdaModel
from sklearn import linear_model
from sklearn.datasets import fetch_20newsgroups
from sklearn.feature_extraction.text import CountVectorizer