Skip to content

Instantly share code, notes, and snippets.

@nbro
nbro / policy_iteration.py
Created December 16, 2017 15:59
Simple example of policy iteration on a grid/maze world (using Python/NumPy)
import numpy as np
E = EMPTY = 0
B = BLOCKED = 1
G = GOAL = 2
# The maze from the assignment
MAZE = np.array(
[[0, 0, 0, 0, 0, 0, 0],
[0, 0, B, 0, 0, 0, 0],
@nbro
nbro / knuth_problem.py
Last active January 22, 2021 21:41
Knuth Problem (described in section 3.2 of the 3rd edition of the book "Artificial Intelligence: A Modern Approach", p. 73) with Tree-based Genetic Programming
# You need to have graphviz installed
# if you want to plot the trees (commented for now).
# It doesn't seem to find the right solution.
# The best solution seems to be: floor(sqrt(float(sqrt(4)))),
# which produces 1, so it has a fitness of 4.
import math
import operator
import random
import sys
@nbro
nbro / test_trainable_prior.py
Created April 17, 2020 16:24 — forked from cboulay/test_trainable_prior.py
Some testing code for tensorflow-probability trainable priors
import numpy as np
import matplotlib.pyplot as plt
import tensorflow as tf
import tensorflow.keras.layers as tfkl
from tensorflow.keras import backend as K
import tensorflow_probability as tfp
tfd = tfp.distributions
tfpl = tfp.layers
tfb = tfp.bijectors
@nbro
nbro / dictionary_as_model_output.py
Created January 31, 2020 12:31
In TF 2.1 (at least), you can create a model by passing to the outputs parameter a dictionary.
def example1():
# TensorFlow 2.1
import tensorflow as tf
import numpy as np
Input_1 = tf.keras.layers.Input(shape=(1,))
x = tf.keras.layers.Dense(100, activation='relu')(Input_1)
targets = ["out1", "out2", "out3"]

Mounting VirtualBox shared folders on Ubuntu Server 16.04 LTS

This guide will walk you through steps on how to setup a VirtualBox shared folder inside your Ubuntu Server guest. Tested on Ubuntu Server 16.04.3 LTS (Xenial Xerus)

Steps:

  1. Open VirtualBox
  2. Right-click your VM, then click Settings
  3. Go to Shared Folders section
  4. Add a new shared folder
  5. On Add Share prompt, select the Folder Path in your host that you want to be accessible inside your VM.
@nbro
nbro / mnist_example.py
Last active January 5, 2019 21:20
PyTorch example to train a CNN on MNIST using VisualDL for logging
# It takes about 8 minutes to train this model and obtain 99% accuracy.
from __future__ import print_function
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torchvision import datasets, transforms
import time
import datetime
import argparse
@nbro
nbro / game-tree.tex
Created October 21, 2018 20:41
Game tree template to be included in main.tex
\def\alphabetadiagram{
\begin{tikzpicture}[-, >=stealth', level/.style={sibling distance = 8cm/#1, level distance = 2cm}]
\node [circle_node] (A) {$+$}
child { node [square_node] (B) {-}
child { node [circle_node] (E) {+}
child { node [square_node] (L) {-}
child [sibling distance = 1cm] { node [circle_node] (V) {$7$} }
child [sibling distance = 1cm] { node [circle_node] (W) {$4$} }
}
@nbro
nbro / main.tex
Created October 21, 2018 20:39
Main file which imports the template in the file game-tree.tex
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usepackage[margin=0.6in]{geometry}
% Define a few styles for the nodes
\tikzset{
tree_node/.style = {align=center, inner sep=0pt, text centered, font=\sffamily},
square_node/.style = {tree_node, rectangle, draw=black, minimum width=1.5em, minimum height=1.5em, very thick},
@nbro
nbro / template.tex
Created October 21, 2018 19:03
Code to be made a template
\begin{tikzpicture}[-, >=stealth', level/.style={sibling distance = 8cm/#1, level distance = 2cm}]
\node [circle_node] (A) {$+$}
child { node [square_node] (B) {-}
child { node [circle_node] (E) {+}
child { node [square_node] (L) {-}
child [sibling distance = 1cm] { node [circle_node] (V) {$7$} }
child [sibling distance = 1cm] { node [circle_node] (W) {$4$} }
}
child { node [square_node] (M) {-}
child [sibling distance = 1cm] { node [circle_node] (X) {$2$} }

channel operator quick reference

direct discussion about administrative action away from the main channel and into #reddit-diabetes-ops to minimise disruption. our -ops channel is the place where users should come to ask for our help. examples:

  • any sort of operator request or discussion of channel administration in the main channel
  • PMs asking why a ban was set
  • reports of harassment (unless the user is confiding in you)
  • any request for operator action

changing channel access permissions