Skip to content

Instantly share code, notes, and snippets.

View post2web's full-sized avatar

Ivelin Angelov post2web

  • Intuit Inc
  • San Diego, CA
View GitHub Profile
@post2web
post2web / 2D3D_MaxMean_pooling.py
Created June 22, 2018 16:56
max mean pooling with numpy for 2d and 3d data
# from https://stackoverflow.com/questions/42463172/how-to-perform-max-mean-pooling-on-a-2d-array-using-numpy
import numpy as np
def asStride(arr,sub_shape,stride):
'''Get a strided sub-matrices view of an ndarray.
See also skimage.util.shape.view_as_windows()
'''
s0,s1=arr.strides[:2]
m1,n1=arr.shape[:2]
m2,n2=sub_shape
view_shape=(1+(m1-m2)//stride[0],1+(n1-n2)//stride[1],m2,n2)+arr.shape[2:]
import tensorflow as tf
train_dataset = tf.data.Dataset.range(10)
train_iterator = train_dataset.make_one_shot_iterator()
train_next = train_iterator.get_next()
test_dataset = tf.data.Dataset.range(10, 20)
test_iterator = test_dataset.make_one_shot_iterator()
test_next = test_iterator.get_next()
@post2web
post2web / autoreload.md
Created May 3, 2018 19:54 — forked from deehzee/autoreload.md
Auto reload of modules in jupyter notebook

Module autoreload

To auto-reload modules in jupyter notebook (so that changes in files *.py doesn't require manual reloading):

# for auto-reloading external modules
# see http://stackoverflow.com/questions/1907993/autoreload-of-modules-in-ipython
%load_ext autoreload
%autoreload 2
@post2web
post2web / gcloud-port-forward.md
Last active March 30, 2018 03:40 — forked from jibs/gcloud-port-forward.md
port forwarding with a google cloud instance

gcloud compute ssh instance-0 --ssh-flag="-L 8888:localhost:8888"

@post2web
post2web / tensorflow-gpu-setup.sh
Last active March 30, 2018 18:02 — forked from mjdietzx/waya-dl-setup.sh
Install CUDA 9, cuDNN v7.1, tensorflow-gpu on Ubuntu 16.04
# cuda 9
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda-repo-ubuntu1704-9-0-local_9.0.176-1_amd64-deb
sudo dpkg -i cuda-repo-ubuntu1704-9-0-local_9.0.176-1_amd64-deb
sudo apt-key adv --fetch-keys \
http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda-9-0
# cuDNN 7.05
@post2web
post2web / update pip package
Created February 3, 2018 19:53
update pip package
pip install -U pip setuptools twine
Edit ~/.pypirc and comment out or remove repository:
[pypi]
#repository:https://pypi.python.org/pypi
Use twine to upload your module to pypi from within the folder containing the module source, setup.py, and other files:
python setup.py sdist
writer = tf.summary.FileWriter(logdir='checkpoints', graph=sess.graph)
writer.flush()
@post2web
post2web / gpu.py
Created December 27, 2017 22:01
tensorflow use gpu #0 in jupyter
%env CUDA_VISIBLE_DEVICES=0
# https://help.ubuntu.com/community/AptGet/Howto
# run after changing /etc/apt/sources.list or /etc/apt/preferences
apt-get update
# upgrade all installed packages
apt-get upgrade
# upgrade all installed packages with "smart" conflict resolution
apt-get dist-upgrade
Generate a rsa keypair:
# ssh-keygen
then copy it on the server with one simple command:
# ssh-copy-id hostname
you can now log in without password:
# ssh hostname