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
// Sample output: | |
// | |
// Win probability for first move with random agents: | |
// 0.115 0.102 0.116 | |
// 0.102 0.131 0.101 | |
// 0.116 0.102 0.116 | |
// Player 1 won 584650 times | |
// Player 2 won 288379 times | |
// 126971 ties | |
// 0.035250 seconds |
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 math | |
class Line: | |
def __init__(self, x1, y1, x2, y2): | |
self.x1 = x1 | |
self.y1 = y1 | |
self.x2 = x2 | |
self.y2 = y2 | |
def to_svg(self, style): |
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 z3 import * | |
import matplotlib.pyplot as plt | |
import random, math | |
# pip install z3-solver matplotlib | |
# do not install z3, that's a different library | |
random.seed(0) | |
def find_ordered_coloring(edges, n): |
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 matplotlib.pyplot as plt | |
import matplotlib | |
# ugly hack to embed fonts | |
matplotlib.rc("pdf", fonttype=42) | |
edgecolor = "black" | |
bar_scale = 0.8 |
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 subprocess, getpass | |
def get_gpu_usage(): | |
""" | |
Returns a dict which contains information about memory usage for each GPU. | |
In the following output, the GPU with id "0" uses 5774 MB of 16280 MB. | |
253 MB are used by other users, which means that we are using 5774 - 253 MB. | |
{ |
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 blenderproc as bproc | |
import numpy as np | |
bproc.init() | |
# Create a simple object: | |
obj = bproc.object.create_primitive("MONKEY") | |
# Create a point light next to it | |
light = bproc.types.Light() |
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 pyopencl as cl | |
from pymatting import KDTree | |
import pymatting | |
import time | |
source = """ | |
typedef int int32_t; | |
typedef long int64_t; |
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
Colors: | |
[[255, 128, 128], [255, 174, 128], [255, 221, 128], [213, 255, 128], [128, 255, 183], [128, 255, 253], [128, 208, 255], [128, 151, 255], [198, 128, 255], [255, 128, 202]] | |
RGB colors in unit range: | |
(1.00, 0.50, 0.50), (1.00, 0.68, 0.50), (1.00, 0.87, 0.50), (0.84, 1.00, 0.50), (0.50, 1.00, 0.72), (0.50, 1.00, 0.99), (0.50, 0.82, 1.00), (0.50, 0.59, 1.00), (0.78, 0.50, 1.00), (1.00, 0.50, 0.79) | |
Colors in hexadecimal: | |
['#ff8080', '#ffae80', '#ffdd80', '#d5ff80', '#80ffb7', '#80fffd', '#80d0ff', '#8097ff', '#c680ff', '#ff80ca'] |
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 cv2 | |
import numpy as np | |
import urllib.request | |
import os | |
# Download Tsukuba stereo test images | |
urls = [ | |
"https://vision.middlebury.edu/stereo/data/scenes2001/data/tsukuba/scene1.row3.col1.ppm", | |
"https://vision.middlebury.edu/stereo/data/scenes2001/data/tsukuba/scene1.row3.col2.ppm", | |
] |
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
#include <cuda_runtime.h> | |
#include <iostream> | |
#define CHECK_CUDA_ERROR(call) \ | |
do { \ | |
cudaError_t err = call; \ | |
if (err != cudaSuccess) { \ | |
std::cerr << "CUDA error at " << __FILE__ << ":" << __LINE__ << " - " \ | |
<< cudaGetErrorString(err) << " (" << err << ")" << std::endl; \ | |
exit(EXIT_FAILURE); \ |
OlderNewer