Skip to content

Instantly share code, notes, and snippets.

View adamconkey's full-sized avatar

Adam Conkey adamconkey

View GitHub Profile
@adamconkey
adamconkey / view_torch_kl_options.py
Last active October 19, 2020 18:28
See all of the possible distribution combinations that can be used in PyTorch's kl_divergence function.
from torch.distributions.kl import _KL_REGISTRY
def view_kl_options():
"""
Displays all combinations of distributions that can be used in
torch's kl_divergence function. Iterates through the registry
and prints out the registered name combos.
"""
names = [(k[0].__name__, k[1].__name__) for k in _KL_REGISTRY.keys()]
max_name_len = max([len(t[0]) for t in names])
@adamconkey
adamconkey / generate_random_rgb_colors.py
Created July 3, 2020 19:30
Function to generate random RGB tuples using Seaborn color palettes.
import random
import seaborn as sns
def random_colors(n_colors, palette='hls', xkcd_colors=[]):
"""
Generates list of random RGB colors.
Args:
n_colors (int): Number of random colors to return.
@adamconkey
adamconkey / trajectory_visualization.py
Created September 17, 2018 18:31
Trajectory visualization in rViz using Marker types to create solid or dotted lines tracking a point as it traverses in space (e.g. the trace of the end-effector as it moves through space).
#!/usr/bin/env python
import sys
import rospy
from matplotlib import colors
from geometry_msgs.msg import Point, PoseStamped
from visualization_msgs.msg import Marker
# Log levels
INFO = 0
WARN = 1