Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View masterdezign's full-sized avatar

masterdezign

View GitHub Profile
import numpy as np
def spirals(n_samples=400):
N = n_samples
theta = np.sqrt(np.random.rand(N))*2*np.pi
r_a = 2*theta + np.pi
data_a = np.array([np.cos(theta)*r_a, np.sin(theta)*r_a]).T
x_a = data_a + np.random.randn(N,2)
@masterdezign
masterdezign / buffers.py
Last active April 8, 2024 08:32
Recurrent replay buffer
from copy import deepcopy
from typing import Any, Dict, Generator, List, Optional, Union
from typing import NamedTuple, Tuple
from gymnasium import spaces
import numpy as np
import torch as th
from stable_baselines3.common.buffers import BaseBuffer
from stable_baselines3.common.vec_env import VecNormalize
@masterdezign
masterdezign / charnn.py
Last active April 1, 2024 20:02
Character-level text generation with PyTorch LSTM
# Based on min-char-rnn.py
# https://gist.github.com/karpathy/d4dee566867f8291f086
import torch as th
import torch.nn as nn
import numpy as np
class Model(nn.Module):
def __init__(self, hidden_size, vocab_size, num_layers):
@masterdezign
masterdezign / Dockerfile
Last active December 20, 2023 20:00
Configuration for reinforcement learning with Gymnasium
FROM pytorch/pytorch:2.1.0-cuda11.8-cudnn8-runtime
ARG USER="user"
ARG UID="1000"
ARG GID="100"
USER "root"
RUN apt-get update && apt-get install -y gnupg
Edit wpa_supplicant.conf and save it to the root of boot partition.
Replace the country code, ssid, and psk.
Full list of country codes: https://www.thinkpenguin.com/gnu-linux/country-code-list
On first boot, this file will be moved to /etc/wpa_supplicant/wpa_supplicant.conf where it may be edited later.
@masterdezign
masterdezign / install-ghc.md
Created December 5, 2015 14:36 — forked from yantonov/install-ghc-ubuntu.md
How to install latest GHC 7.10.2 from source + stack 0.1.6.0 + cabal 1.22.4.0 + cabal-install 1.22.6.0 on ubuntu

How to install latest GHC 7.10.2 from source + stack 0.1.6.0 + cabal 1.22.4.0 + cabal-install 1.22.6.0 on ubuntu

for your convinience these instuction is available as:
gist
git repo

settings

GHC_VERSION="7.10.2"  

ARCHITECTURE="x86_64"

@masterdezign
masterdezign / brainf.hs
Last active April 22, 2022 16:38
Brainf**k interpreter in Haskell.
{-
Brainf**k interpreter
Brainf**k is a Turing-complete programming language.
Instructions:
> Increment data pointer so that it points to next location in memory.
< Decrement data pointer so that it points to previous location in memory.
+ Increment the byte pointed by data pointer by 1. If it is already at its maximum value, 255, then new value will be 0.
- Decrement the byte pointed by data pointer by 1. If it is at its minimum value, 0, then new value will be 255.
@masterdezign
masterdezign / docker-compose.yml
Created March 3, 2022 15:51
Docker compose MySQL + PHPMyadmin
version: '3.1'
services:
db:
image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: CHANGE_THIS_PASSWORD
MYSQL_DATABASE: test_db
@masterdezign
masterdezign / cuda_11.2_installation_on_Ubuntu_20.04
Created February 16, 2022 10:32 — forked from Mahedi-61/cuda_11.8_installation_on_Ubuntu_22.04
Instructions for CUDA v11.2 and cuDNN 8.1 installation on Ubuntu 20.04 for Pytorch 1.8 & Tensorflow 2.7.0
#!/bin/bash
### steps ####
# verify the system has a cuda-capable gpu
# download and install the nvidia cuda toolkit and cudnn
# setup environmental variables
# verify the installation
###
### to verify your gpu is cuda enable check
@masterdezign
masterdezign / convex-hull.hs
Last active January 21, 2022 00:28
Convex hull algorithm in Haskell
-- Worth reading http://www.geeksforgeeks.org/convex-hull-set-2-graham-scan/
import Text.Printf
import Data.List
type Point = (Double, Double)
-- Euclidean distance
dist :: (Double, Double) -> (Double, Double) -> Double
dist (x1, y1) (x2, y2) = sqrt (f x1 x2 + f y1 y2)