Skip to content

Instantly share code, notes, and snippets.

View DuaneNielsen's full-sized avatar
👾
Happy!

Duane DuaneNielsen

👾
Happy!
View GitHub Profile
@DuaneNielsen
DuaneNielsen / drone_drop.py
Last active February 9, 2024 07:53
Demo of how to create a body in pymunk and apply a force
import pymunk
import pygame
import random
import sys
from pymunk.pygame_util import DrawOptions
width = 600
height = 600
import torch
import torch.nn as nn
from torch.autograd import Variable
from torch.nn.utils.rnn import pack_padded_sequence, pad_packed_sequence
import itertools
import string
"""
Since character embeddings are a bit weak in pytorch 3, this will hopefully help out
I think these should be trainable and also, invertable!
dependencies
virtualenv
http://virtualenvwrapper.readthedocs.io/en/latest/command_ref.html
sudo pip install vitualenvwrapper
in .bash_profile add (or create)
from typing import Optional
import torch
from torch import tensor
from tensordict import TensorDict
from torchrl.data import CompositeSpec, BoundedTensorSpec, UnboundedContinuousTensorSpec, UnboundedDiscreteTensorSpec, DiscreteTensorSpec, \
UnboundedContinuousTensorSpec
from torchrl.envs import (
EnvBase,
Transform,
@DuaneNielsen
DuaneNielsen / em_algo_2D.py
Created January 19, 2020 00:37
Expectation Max algo Pytorch
import torch
from torch import tensor
from torch.distributions.multivariate_normal import MultivariateNormal
import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
import matplotlib.patches as mpatches
from math import acos, degrees
from matplotlib.pyplot import cm
"""
@DuaneNielsen
DuaneNielsen / em_algo.py
Created January 15, 2020 05:53
EM algorithm - 1D Uses logprob bayes update for numerical stability
import torch
from torch.distributions.normal import Normal
import matplotlib.pyplot as plt
"""
EM algo demo, in pytorch
"""
n = 40 # must be even number
@DuaneNielsen
DuaneNielsen / pytorch_lightning_mnist_example.py
Created November 24, 2021 20:31
How to use pytorch lightning with bolts
import torch
import torch.nn.functional as F
import pytorch_lightning as pl
from pytorch_lightning.callbacks import ModelCheckpoint, LearningRateMonitor, EarlyStopping
from pytorch_lightning.plugins import DDPPlugin
from pl_bolts.datamodules import MNISTDataModule
class LightningMNISTClassifier(pl.LightningModule):
import torch
import torch.nn.functional as F
import torch.nn as nn
from torch.autograd import Function
from matplotlib import pyplot as plt
from torchvision.io import read_image
inf = float('inf')
http://dev.jackcoldrick.com/custom-form-validation/
@DuaneNielsen
DuaneNielsen / install.sh
Last active April 20, 2021 01:09
setup microk8s
snap install --channel 1.13/stable --classic microk8s
microk8s.enable registry
microk8s.enable dns
microk8s.enable storage # not sure if i need this
#install
snap install helm --classic
/snap/bin/helm init
helm install stable/redis -n ppo-redis
snap alias microk8s.kubectl kubectl