Skip to content

Instantly share code, notes, and snippets.

View ktl014's full-sized avatar

Kevin Tran Vu Le ktl014

  • University of California, San Diego
  • La Jolla, CA
View GitHub Profile
# AlexNet
name: "AlexNet"
layer {
name: "train-data"
type: "Data"
top: "data"
top: "label"
transform_param {
mirror: false
crop_size: 227
@ktl014
ktl014 / kernel.py
Created August 7, 2018 16:12
kernel approximation using svm
from sklearn.kernel_approximation import RBFSampler
from sklearn.decomposition import PCA
kernel_svm = svm.SVC(gamma=.2)
linear_svm = svm.LinearSVC()
feature_map_fourier = RBFSampler(gamma=.2, random_state=SEED)
feature_map_nystroem = Nystroem(gamma=.2, random_state=SEED)
fourier_approx_svm = pipeline.Pipeline([("feature_map", feature_map_fourier),
("svm", svm.LinearSVC())])
# Importing data from csv file
csv_filename = './tweets.csv'
dataset = tf.contrib.data.make_csv_dataset(csv_filename, batch_size=32)
dataset = dataset.shuffle(buffer_size=100)
iter = dataset.make_one_shot_iterator()
next = iter.get_next()
features, labels = next['text'], next['sentiment']
with tf.Session() as sess:
sess.run([features, labels])
#! /usr/bin/env python
from __future__ import absolute_import, division, print_function
import os
import matplotlib.pyplot as plt
import tensorflow as tf
import keras
import tensorflow.contrib.eager as tfe
@ktl014
ktl014 / urllib.py
Created May 25, 2018 19:11
how to open urls with urllib
from urllib.request import urlopen
html = urlopen("http://www.google.com/")
print(html)
name: "ResNet-50"
layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
transform_param {
@ktl014
ktl014 / train_val_exp2.prototxt
Last active May 30, 2018 03:06
CaffeNet model
name: "AlexNet"
layer {
name: "data"
type: "Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
# transform_param {
name: "VGG_ILSVRC_16_layers"
layer {
name: "data"
type: "Data"
include {
phase: TRAIN
}
transform_param {
crop_size: 224
mean_value: 104
name: "VGG_ILSVRC_19_layers"
input: "data"
input_dim: 10
input_dim: 3
input_dim: 224
input_dim: 224
layers {
bottom: "data"
top: "conv1_1"
name: "conv1_1"
>>> class Library(object):
... def __init__(self):
... self.books = { 'title' : object, 'title2' : object, 'title3' : object, }
... def __getitem__(self, i):
... return self.books[i]
... def __iter__(self):
... return self.books.itervalues()
...
>>> library = Library()
>>> library['title']