Skip to content

Instantly share code, notes, and snippets.

View araffin's full-sized avatar

Antonin RAFFIN araffin

View GitHub Profile
@araffin
araffin / halfcheetah_minimal.py
Last active March 27, 2024 11:55
Minimal implementation to solve the HalfCheetah env using open-loop oscillators
import gymnasium as gym
import numpy as np
from gymnasium.envs.mujoco.mujoco_env import MujocoEnv
# Env initialization
env = gym.make("HalfCheetah-v4", render_mode="human")
# Wrap to have reward statistics
env = gym.wrappers.RecordEpisodeStatistics(env)
mujoco_env = env.unwrapped
n_joints = 6
import gymnasium as gym
import numpy as np
from gymnasium.envs.mujoco.mujoco_env import MujocoEnv
# Env initialization
env = gym.make("Swimmer-v4", render_mode="human")
# Wrap to have reward statistics
env = gym.wrappers.RecordEpisodeStatistics(env)
mujoco_env = env.unwrapped
n_joints = 2
@nmwsharp
nmwsharp / printarr
Last active October 24, 2023 08:06
Pretty print tables summarizing properties of tensor arrays in numpy, pytorch, jax, etc. --- now on pip: `pip install arrgh`
Pretty print tables summarizing properties of tensor arrays in numpy, pytorch, jax, etc.
Now on pip! `pip install arrgh` https://github.com/nmwsharp/arrgh
import urllib.request
from datetime import datetime
import wandb
import yaml
from yaml.loader import SafeLoader
atari_ids = [
# "AdventureNoFrameskip-v4",
# "AirRaidNoFrameskip-v4",
@Starbuck5
Starbuck5 / ascii_video_player.py
Created April 10, 2022 10:03
ASCII Video Player
import cv2
import pygame
import numpy
import functools
# WHAT IS THIS?
# This script is a simple ascii video player made in Python / pygame
# It allows you to drop in videos, or to use the webcam
pygame.init()
@Miffyli
Miffyli / assign-credits.py
Last active September 16, 2022 17:28
A very useful script for making sure everyone is credited accordingly
# A very useful script for giving credit where it is due: by replacing (most) variable names by the authors who wrote them.
# Requirements: pip install gitpython
# Usage: python3 assign-credits.py <input_file> <output_file>
# Example: python3 assign-credits.py ./src/main.py ./src/main-credited.py
# NOTE that this is an awful idea with an awful implementation. The "generated" code likely does not work
# (e.g. typing stuff is skipped, class attribute names are replaced). The "author" is decided by the current HEAD of git repo, and whoever
# defines the variable first will get the credits (hahaa dunno if even this is right).
# It is getting late and I am tired of typing so I will let Github Copilot write something for me.
@mike10004
mike10004 / inject.py
Created November 1, 2018 14:47
David Buchanan's JPEG injection code
#!/usr/bin/python3
"""
WARNING: The code you are about to view is DISGUSTING
I wrote most of it months ago, so don't ask me what it's doing, or why.
"""
import struct
import sys
@InnovArul
InnovArul / tied_linear.py
Last active April 11, 2024 11:01
tied linear layer experiment
import torch, torch.nn as nn, torch.nn.functional as F
import numpy as np
import torch.optim as optim
# tied autoencoder using off the shelf nn modules
class TiedAutoEncoderOffTheShelf(nn.Module):
def __init__(self, inp, out, weight):
super().__init__()
self.encoder = nn.Linear(inp, out, bias=False)
self.decoder = nn.Linear(out, inp, bias=False)
@fgolemo
fgolemo / pytorch-on-raspberry-pi3.md
Created March 7, 2018 14:28
How to install PyTorch v0.3.1 on RaspberryPi 3B - Tutorial

How to install PyTorch v0.3.1 on RaspberryPi 3B

Prerequisites

Important I'd recommend you use at least a 16GB sd card. I tried it with an 8GB card and it baaaaarely fits. I had to uninstall a lot of packages and regularly clean up.

Go to https://www.raspberrypi.org/downloads/raspbian/ and download the Raspbian Stretch image (either one).

Use Etcher (from https://etcher.io/) to "burn" the image onto the SD card.

anonymous
anonymous / time-awareness.ipynb
Created January 4, 2018 09:55
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.