This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Trains an agent with (stochastic) Policy Gradients on Pong. Uses OpenAI Gym. """ | |
import numpy as np | |
#import cPickle as pickle | |
import _pickle as pickle | |
import gym | |
# hyperparameters | |
H = 200 # number of hidden layer neurons | |
batch_size = 10 # every how many episodes to do a param update? | |
learning_rate = 1e-4 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Feature extractor | |
def extract_features(image_path, vector_size=32): | |
image = imread(image_path, mode="RGB") | |
try: | |
# Using KAZE, cause SIFT, ORB and other was moved to additional module | |
# which is adding addtional pain during install | |
alg = cv2.KAZE_create() | |
# Dinding image keypoints | |
kps = alg.detect(image) | |
# Getting first 32 of them. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""disjoint_set.py | |
""" | |
import random | |
class DisjointSet(object): | |
"""DisjointSet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" JK Jung's .vmirc | |
" | |
" Reference: | |
" | |
" 1. Sample .vimrc by Martin Brochhaus, presented at PyCon APAC 2012 | |
" https://github.com/mbrochh/vim-as-a-python-ide | |
" 2. https://realpython.com/vim-and-python-a-match-made-in-heaven/ | |
" 3. https://github.com/fisadev/fisa-vim-config | |
" 4. https://github.com/thesheff17/youtube/blob/master/vim/vimrc | |
" 5. https://github.com/amix/vimrc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -------------------------------------------------------- | |
# Camera Recorder for Tegra X2/X1 | |
# | |
# This program captures video from IP CAM, USB webcam, | |
# or the Tegra onboard camera, adds some watermark on | |
# the video frames and then records it into a TS file. | |
# The code demonstrates how to use cv2.VideoWriter() | |
# while taking advantage of TX2/TX1's H.264 H/W encoder | |
# capabilities. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reference: https://michhar.github.io/how-i-built-pytorch-gpu/ | |
# I have a GTX-1080 and a GTX-2080 Ti, thus CUDA_ARCH "6.1" and "7.5". | |
# Patch cmake if necessary: https://github.com/arrayfire/arrayfire/issues/2330 | |
git clone https://github.com/pytorch/pytorch.git pytorch-v1.3.1 | |
cd pytorch-v1.3.1 | |
git checkout v1.3.1 | |
git submodule update --init --recursive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import struct | |
lines = Path('calib_yolov4-int8-608.bin').read_text().splitlines() | |
for line in lines: | |
pair = line.split(':') | |
if len(pair) != 2: | |
continue | |
assert len(pair[1]) == 9 | |
bstr = bytes.fromhex(pair[1][1:]) # convert to byte string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import keras | |
class DataGenerator(keras.utils.Sequence): | |
'Generates data for Keras' | |
def __init__(self, list_IDs, labels, batch_size=32, dim=(32,32,32), n_channels=1, | |
n_classes=10, shuffle=True): | |
'Initialization' | |
self.dim = dim | |
self.batch_size = batch_size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""dcgan_mnist.py | |
This script was orginally written by Rowel Atienza (see below), and | |
was modified by JK Jung <jkjung13@gmail.com>. | |
------ | |
DCGAN on MNIST using Keras | |
Author: Rowel Atienza | |
Project: https://github.com/roatienza/Deep-Learning-Experiments |
OlderNewer