Skip to content

Instantly share code, notes, and snippets.

from __future__ import print_function
import argparse
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
import datetime
@salihkaragoz
salihkaragoz / conv_5.py
Last active April 29, 2018 15:06
Cifar 10 arc
def five_convnet(X, model, y=None, reg=0.0):
W1, b1, W2, b2 = model['W1'], model['b1'], model['W2'], model['b2']
W3, b3, W4, b4 = model['W3'], model['b3'], model['W4'], model['b4']
W5, b5, W6, b6 = model['W5'], model['b5'], model['W6'], model['b6']
conv_filter_height, conv_filter_width = W1.shape[2:]
assert conv_filter_height == conv_filter_width, 'Conv filter must be square'
assert conv_filter_height % 2 == 1, 'Conv filter height must be odd'
@salihkaragoz
salihkaragoz / installer.bash
Last active April 20, 2018 11:55
install python3 from source
mkdir /truba/home/{username}/python3
cd python3
wget https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgz
tar zxfv Python-3.5.2.tgz
cd Python-3.5.2.tgz
./configure --prefix=/truba/home/{username}/python3
make && make install
export PATH=/truba/home/{username}/python3/Python-3.5.2/:$PATH
export PYTHONPATH=/truba/home/{username}/python3/Python-3.5.2
@salihkaragoz
salihkaragoz / coco_getcat.py
Last active May 23, 2019 12:52
COCO categories
import json
data = json.load(open('instances_train2017.json'))
print data.keys()
#OUTPUT :
# [u'info', u'licenses', u'images', u'annotations', u'categories']
print data['categories']
'''
@salihkaragoz
salihkaragoz / labels_1024.tsv
Created February 6, 2018 17:54 — forked from teamdandelion/labels_1024.tsv
TensorBoard: TF Dev Summit Tutorial
We can make this file beautiful and searchable if this error is corrected: No tabs found in this TSV file in line 0.
7
2
1
0
4
1
4
9
5
9
@salihkaragoz
salihkaragoz / convertor.py
Last active January 26, 2018 06:17
Convert PNGs to JPGs under a folder with opencv
# Written by MSK
import glob
import cv2
pngs = glob('./*.png')
for png in pngs:
img = cv2.imread(png)
cv2.imwrite(png[:-3] + 'jpg', img)
@salihkaragoz
salihkaragoz / train.py
Last active December 15, 2017 11:41
Training
import numpy as np
from pycocotools.coco import COCO
import os
import math
import keras
from keras.models import Sequential, Model
from keras.layers import Dense, Activation, Input, Flatten, Dropout
from keras.utils import plot_model
import cv2
import matplotlib.pyplot as plt
@salihkaragoz
salihkaragoz / focal_loss_theano
Last active April 20, 2018 13:05
keras focal loss theano backend
y_true = 2
y_pred = 0.2
if(K.backend()=="tensorflow"):
import tensorflow as tf
sess= tf.Session()
with tf.device('/cpu:0'):
pt = tf.where(tf.equal(y_true, 1), y_pred, 1 - y_pred)
print(sess.run(pt))
if(K.backend()=="theano"):
@salihkaragoz
salihkaragoz / readme.md
Created September 22, 2017 06:18 — forked from baraldilorenzo/readme.md
VGG-16 pre-trained model for Keras

##VGG16 model for Keras

This is the Keras model of the 16-layer network used by the VGG team in the ILSVRC-2014 competition.

It has been obtained by directly converting the Caffe model provived by the authors.

Details about the network architecture can be found in the following arXiv paper:

Very Deep Convolutional Networks for Large-Scale Image Recognition

K. Simonyan, A. Zisserman

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name: