Skip to content

Instantly share code, notes, and snippets.

View foobar167's full-sized avatar
🧠
Researching

FooBar167 foobar167

🧠
Researching
View GitHub Profile
#https://cs231n.github.io/neural-networks-case-study/
def spiral_data(points, classes):
X = np.zeros((points*classes, 2))
y = np.zeros(points*classes, dtype='uint8')
for class_number in range(classes):
ix = range(points*class_number, points*(class_number+1))
r = np.linspace(0.0, 1, points) # radius
t = np.linspace(class_number*4, (class_number+1)*4, points) + np.random.randn(points)*0.2
X[ix] = np.c_[r*np.sin(t*2.5), r*np.cos(t*2.5)]
y[ix] = class_number
@AntonovMikhail
AntonovMikhail / DP0701EN-3-3-1-Clustering-k-means-py-v1.0.ipynb
Created September 29, 2019 15:39
Created on Cognitive Class Labs
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@malkayo
malkayo / tensorflow-high-level-apis-notebook.ipynb
Created February 3, 2019 16:13
TensorFlow high-level APIs - Notebook.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import nibabel as nib
import numpy as np
data = np.ones((32, 32, 15, 100), dtype=np.int16) # dummy data in numpy matrix
img = nib.Nifti1Image(data, np.eye(4)) # Save axis for data (just identity)
img.header.get_xyzt_units()
img.to_filename(os.path.join('build','test4d.nii.gz')) # Save as NiBabel file
@jayspeidell
jayspeidell / kaggle_download.py
Last active July 18, 2023 12:23
Sample script to download Kaggle files
# Info on how to get your api key (kaggle.json) here: https://github.com/Kaggle/kaggle-api#api-credentials
!pip install kaggle
api_token = {"username":"USERNAME","key":"API_KEY"}
import json
import zipfile
import os
with open('/content/.kaggle/kaggle.json', 'w') as file:
json.dump(api_token, file)
!chmod 600 /content/.kaggle/kaggle.json
!kaggle config path -p /content
@qfgaohao
qfgaohao / ssd_priors.py
Last active November 27, 2019 08:06
Generate SSD Prior Boxes.
import collections
import numpy as np
import itertools
SSDBoxSizes = collections.namedtuple('SSDBoxSizes', ['min', 'max'])
Spec = collections.namedtuple('Spec', ['feature_map_size', 'shrinkage', 'box_sizes', 'aspect_ratios'])
# the SSD orignal specs
specs = [
import numpy as np
from keras import backend as K
from keras.models import Sequential
from keras.layers.core import Dense, Dropout, Activation, Flatten
from keras.layers.convolutional import Convolution2D, MaxPooling2D
from keras.preprocessing.image import ImageDataGenerator
from sklearn.metrics import classification_report, confusion_matrix
#Start
train_data_path = 'F://data//Train'
@gornostal
gornostal / Unicode.md
Created November 22, 2015 10:15
Python 2.7. Unicode Errors Simply Explained

Python 2.7. Unicode Errors Simply Explained

I know I'm late with this article for about 5 years or so, but people are still using Python 2.x, so this subject is relevant I think.

Some facts first:

  • Unicode is an international encoding standard for use with different languages and scripts
  • In python-2.x, there are two types that deal with text.
    1. str is an 8-bit string.
  1. unicode is for strings of unicode code points.
@andreipak
andreipak / cfg_copy_db_section.py
Created October 23, 2014 06:46
copy config keys within section using ConfigParser
import ConfigParser, os
config_src = ConfigParser.ConfigParser()
config_dst = ConfigParser.ConfigParser()
config_keys = "host user passwd name".split()
config_keys.reverse()
dst_cfg_path = 'cfg1.ini'
src_cfg_path = 'cfg2.ini'
@TravisJoe
TravisJoe / tkinter_full_test.py
Created May 14, 2013 14:17
Tkinter in python full screen example
from Tkinter import *
root = Tk()
w = Label(root, text="Hello, world!")
root.overrideredirect(True)
root.geometry("{0}x{1}+0+0".format(root.winfo_screenwidth(), root.winfo_screenheight()))
root.focus_set() # <-- move focus to this widget
root.bind("<Escape>", lambda e: e.widget.quit())
w.pack()