This file contains hidden or 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 time import sleep | |
| from urllib.request import Request, urlopen | |
| import argparse | |
| import json | |
| import traceback | |
| GITHUB_REPOS_API = 'https://api.github.com/users/{user_name}/repos?per_page=100&page={page}' | |
| PRINT_LINE = '{repo_name: <40}:{star_cnt: >6}' | |
| p = argparse.ArgumentParser() |
This file contains hidden or 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
| # Copyright (c) 2019-present, Thomas Wolf. | |
| # All rights reserved. This source code is licensed under the MIT-style license. | |
| """ A very small and self-contained gist to train a GPT-2 transformer model on wikitext-103 """ | |
| import os | |
| from collections import namedtuple | |
| from tqdm import tqdm | |
| import torch | |
| import torch.nn as nn | |
| from torch.utils.data import DataLoader | |
| from ignite.engine import Engine, Events |
This file contains hidden or 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
| def pca(X): | |
| # Data matrix X, assumes 0-centered | |
| n, m = X.shape | |
| assert np.allclose(X.mean(axis=0), np.zeros(m)) | |
| # Compute covariance matrix | |
| C = np.dot(X.T, X) / (n-1) | |
| # Eigen decomposition | |
| eigen_vals, eigen_vecs = np.linalg.eig(C) | |
| # Project X onto PC space | |
| X_pca = np.dot(X, eigen_vecs) |
This file contains hidden or 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 __future__ import print_function | |
| import requests | |
| import threading | |
| import sys | |
| def eprint(*args, **kwargs): | |
| print(*args, file=sys.stderr, **kwargs) |
This file contains hidden or 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
| # Online k-means algorithm | |
| # see http://www.cs.princeton.edu/courses/archive/fall08/cos436/Duda/C/sk_means.htm | |
| import numpy as np | |
| def k_means(data, k, threshhold=2): | |
| """ | |
| Does k-means clustering of the data. | |
| Args: |
This file contains hidden or 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 PIL import Image | |
| import sys | |
| # Check arguments | |
| if len(sys.argv) < 3: | |
| print "Usage: python make3d.py <leftimage> <rightimage> <3doutputname>" | |
| quit() | |
| # Open the left and right images | |
| imLeft = Image.open(sys.argv[1]) |
This file contains hidden or 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
| ^ | |
| | 7 | |
| | / | |
| |/ | |
| +-----------> | |
| or | |
| 7 Z-axis |
This file contains hidden or 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
| git config --global http.proxy 'socks5://127.0.0.1:1080' | |
| git config --global https.proxy 'socks5://127.0.0.1:1080' |
This file contains hidden or 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
| ffmpeg -i data/video.mp4 -vcodec h264 -b:v 1000k -acodec mp2 data/output.mp4 |
This file contains hidden or 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
| #!/bin/bash | |
| # | |
| # Script for running `go test` a bunch of times, in parallel, storing the test | |
| # output as you go, and showing a nice status output telling you how you're | |
| # doing. | |
| # | |
| # Normally, you should be able to execute this script with | |
| # | |
| # ./go-test-many.sh | |
| # |
NewerOlder