Skip to content

Instantly share code, notes, and snippets.

View vitasiku's full-sized avatar

Asiku Vitalis vitasiku

View GitHub Profile
@vitasiku
vitasiku / google_drive_util.py
Created July 14, 2017 00:46 — forked from macieksk/google_drive_util.py
A simple Python module to upload files to Google Drive file upload. Needs a file 'client_secrets.json' in the directory . The file can be obtained from https://console.developers.google.com/ -- under APIs&Auth/Credentials/Create Client ID for native application
## Simple Python module to upload files to Google Drive
# Needs a file 'client_secrets.json' in the directory
# The file can be obtained from https://console.developers.google.com/
# under APIs&Auth/Credentials/Create Client ID for native application
# To test usage:
# import google_drive_util
# google_drive_util.login()
# google_drive_util.test()
@vitasiku
vitasiku / building_tensorflow.md
Created August 18, 2017 12:24 — forked from kmhofmann/building_tensorflow.md
Building TensorFlow from source

Building TensorFlow from source

The official instructions on building TensorFlow are here: https://www.tensorflow.org/install/install_sources

Prerequisites

We are assuming a build with CUDA support, as well as including SIMD optimizations (SSE3, SSE4, AVX, AVX2, FMA).

Good to know: The compute capabilities for

  • Maxwell TITAN X: 5.2
@vitasiku
vitasiku / waya-dl-setup.sh
Last active December 6, 2017 09:39 — forked from mjdietzx/waya-dl-setup.sh
Install CUDA Toolkit v8.0 and cuDNN v6.0 on Ubuntu 16.04
#!/bin/bash
# install CUDA Toolkit v8.0
# instructions from https://developer.nvidia.com/cuda-downloads (linux -> x86_64 -> Ubuntu -> 16.04 -> deb (network))
CUDA_REPO_PKG="cuda-repo-ubuntu1604_8.0.61-1_amd64.deb"
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/${CUDA_REPO_PKG}
sudo dpkg -i ${CUDA_REPO_PKG}
sudo apt-get update
sudo apt-get -y install cuda
@vitasiku
vitasiku / gist:f022181d96f4f0dae512d8edbc5f9b98
Created December 8, 2017 10:02 — forked from jagregory/gist:710671
How to move to a fork after cloning
So you've cloned somebody's repo from github, but now you want to fork it and contribute back. Never fear!
Technically, when you fork "origin" should be your fork and "upstream" should be the project you forked; however, if you're willing to break this convention then it's easy.
* Off the top of my head *
1. Fork their repo on Github
2. In your local, add a new remote to your fork; then fetch it, and push your changes up to it
git remote add my-fork git@github...my-fork.git
@vitasiku
vitasiku / setup.py
Created January 21, 2018 22:41
Flask app's cx_freeze's setup.py file.
from cx_Freeze import setup, Executable
include_files = [ 'app/templates/',
'app/static/',]
# Note: without 'jinja2.ext' in this list, we won't get the templates working.
include = [ 'jinja2', 'jinja2.ext',]
flaskapp = Executable(script="run.py",
base="Win32GUI",
class ClusteringQuality:
"""
Instances of this class implement the two measures of clustering quality discussed in the article, namely the davies
bouldin index and the silhouette index. It also implements a number of useful helper methods.
:param solution: the clustering solution of type Clustering
:param minimum: the minimum distance allowable
"""
def __init__(self, solution, minimum):
"""
@vitasiku
vitasiku / KMeansClustering.py
Created February 26, 2019 14:56 — forked from StuartGordonReid/KMeansClustering.py
Implementation of the K-Means Clustering Algorithm
class Clustering:
"""
An instance of the Clustering is a solution i.e. a particular partitioning of the (heterogeneous) data set into
homogeneous subsets. For Centroid based clustering algorithms this involves looking at each pattern and assigning
it to it's nearest centroid. This is done by calculating the distance between each pattern and every centroid and
selecting the one with the smallest distance. Here we use are using fractional distance with the default parameters.
:param d: dimensionality of the input patterns
:param k: the pre-specified number of clusters & centroids
:param z: the patterns in the data set
class Clustering:
def k_means_clustering(self, n, s=1.0):
"""
This method performs the K-means clustering algorithm on the data for n iterations. This involves updating the
centroids using the mean-shift heuristic n-times and reassigning the patterns to their closest centroids.
:param n: number of iterations to complete
:param s: the scaling factor to use when updating the centroids
pick on which has a better solution (according to some measure of cluster quality)
"""
@vitasiku
vitasiku / MonteCarloKMeansClustering.py
Created February 26, 2019 14:58 — forked from StuartGordonReid/MonteCarloKMeansClustering.py
Monte Carlo K-Means Clustering
import math
import random
import csv
import numpy as np
import cProfile
import hashlib
memoization = {}
@vitasiku
vitasiku / py-args-for-bash.sh
Created December 22, 2020 07:56 — forked from benkehoe/py-args-for-bash.sh
Python argument parsing for bash scripts
#!/bin/sh
# This is free and unencumbered software released into the public domain.
#
# Anyone is free to copy, modify, publish, use, compile, sell, or
# distribute this software, either in source code form or as a compiled
# binary, for any purpose, commercial or non-commercial, and by any
# means.
#
# In jurisdictions that recognize copyright laws, the author or authors