The Jax developers optimized a differential equation benchmark in this issue which used DiffEqFlux.jl as a performance baseline. The Julia code from there was updated to include some standard performance tricks and is the benchmark code here. Thus both codes have been optimized by the library developers.
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
# -*- coding: utf-8 -*- | |
import networkx as nx | |
import graph_tool as gt | |
def get_prop_type(value, key=None): | |
""" | |
Performs typing and value conversion for the graph_tool PropertyMap class. | |
If a key is provided, it also ensures the key is in a format that can be | |
used with the PropertyMap. Returns a tuple, (type name, value, key) | |
""" |
Loading
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
# may go to startup file to make it always available | |
# https://github.com/MasonProtter/ReplMaker.jl#creating-a-repl-mode-at-startup-time | |
using ReplMaker | |
function powershell_command(s) | |
# adapted from https://github.com/JuliaLang/julia/blob/7a3fff1ea76b62b7681dbed5cc2dee43c64d9a51/base/client.jl#L45 | |
args = String.(split(s)) | |
if args[1] == "cd" | |
new_oldpwd = pwd() | |
if length(args) > 2 | |
throw(ArgumentError("cd method only takes one argument")) |
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
""" | |
Generate table assignments for 'n' customers, | |
according to a Chinese Restaurant Process with dispersion parameter 'α' | |
Returns an array of integer table assignments | |
""" | |
function crp(n, α) | |
@assert n > 0 | |
table_assignments = zeros(Int, n) | |
table_assignments[1] = 1 # first customer sits at table 1 |
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
border: no | |
height: 600 | |
license: gpl-3.0 |
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
"""Provides methods around syncing and usage of AWS s3 buckets as local caches rather than individually | |
downloading every file""" | |
import os | |
import shutil | |
import boto3 as boto | |
import multiprocessing | |
import copy | |
import hashlib |
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
#Set up data partition | |
sudo mkdir /data | |
sudo chmod 777 /data | |
sudo "echo /dev/xvdb /data ext4 rw,user,exec,comment=cloudconfig 0 2 >> /etc/fstab" | |
sudo mount /data | |
#Install build environment | |
sudo sed -i "s/enabled=0/enabled=1" /etc/yum.repos.d/epel.epo | |
sudo yum -y update | |
sudo yum -y upgrade |
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 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 | |
gamma = 0.99 # discount factor for reward |
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
#!/usr/bin/env python | |
class Vertex: | |
def __init__(self, value): | |
self.value = value | |
self.edges = {} | |
def degree(self): | |
return len(self.edges) | |
def __str__(self): | |
return str(self.value) |