Skip to content

Instantly share code, notes, and snippets.

@rlan
rlan / mnist_ray_pytorch_lightning.py
Last active July 14, 2023 10:32
MNIST training starter kit with Ray, PyTorch Lightning and PyTorch
"""
MNIST PyTorch Lightning Example
Ref: https://docs.ray.io/en/latest/tune/examples/includes/mnist_ptl_mini.html
"""
import math
import torch
from filelock import FileLock
@rlan
rlan / nfs_no_limit_materials_chart.md
Last active March 18, 2022 11:58
NFS no limit materials chart

Materials

Generic

Icon Name Chapters
battery Battery 12.7. 18.3.
hose Hose 7.5. 11.X. 16.8.
bearing Bearing 8.6. 15.X. 18.8.
![relay](h
@rlan
rlan / onenote_vs_evernote.md
Last active March 4, 2022 00:53
OneNote vs EverNote
Evernote OneNote Trello
Free N Y Y
Fast UI Y Y N
Offline mode Y Y Y (mobile app only)
Google Drive integration Y (documents yes, folders not sure) N Y
iOS app Y Y Y
macOS app Y Y Y
"""
Reference: https://github.com/ray-project/ray/blob/f8a91c7fad248b1c7f81fd6d30191ac930a92bc4/rllib/examples/env/simple_corridor.py
Fixes:
ValueError: ('Observation ({}) outside given space ({})!', array([0.]), Box([0.], [999.], (1,), float32))
"""
import gym
from gym.spaces import Box, Discrete
import numpy as np
@rlan
rlan / imagenet.sh
Last active July 30, 2021 11:06 — forked from sharma0611/imagenet.sh
ImageNet Preparation for PyTorch torch vision.datasets.imagenet
#!/bin/bash
#
# These files should exist:
# $ ls
# ILSVRC2012_devkit_t12.tar.gz ILSVRC2012_img_train.tar ILSVRC2012_img_val.tar
#
# When this script is finished:
# $ ls
# imagenet ILSVRC2012_devkit_t12.tar.gz ILSVRC2012_img_train.tar ILSVRC2012_img_val.tar
# $ ls imagenet
@rlan
rlan / requirements.txt
Last active December 26, 2023 04:57
twin-investing
matplotlib
pandas
seaborn
@rlan
rlan / 45231.log
Last active May 25, 2021 12:50
Ray ERROR worker.py:382 -- SystemExit was raised from the worker
[2021-05-24 11:19:29,390 I 45231 22642740] core_worker.cc:136: Constructing CoreWorkerProcess. pid: 45231
[2021-05-24 11:19:29,392 I 45231 22642740] core_worker.cc:356: Constructing CoreWorker, worker_id: 4cb7089af9b4fdf0d82db7aab34b6c55f5d2c379ec4c51d827347638
[2021-05-24 11:19:29,393 I 45231 22642740] grpc_server.cc:71: worker server started, listening on port 56935.
[2021-05-24 11:19:29,398 I 45231 22642740] core_worker.cc:420: Initializing worker at address: 192.168.1.219:56935, worker ID 4cb7089af9b4fdf0d82db7aab34b6c55f5d2c379ec4c51d827347638, raylet 72987f65065c125c627d638cb028d79918cf2929f7353e4ade347e19
[2021-05-24 11:19:29,407 I 45231 22642740] core_worker.cc:285: Worker 4cb7089af9b4fdf0d82db7aab34b6c55f5d2c379ec4c51d827347638 is created.
[2021-05-24 11:19:29,407 I 45231 22642740] io_service_pool.cc:35: IOServicePool is running with 1 io_service.
[2021-05-24 11:19:29,407 I 45231 22644291] service_based_accessor.cc:579: Received notification for node id = 72987f65065c125c627d638cb028d79918cf2929f7353
@rlan
rlan / simple_corridor.py
Last active October 6, 2021 03:53
A starter example that trains, checkpoints and evaluates a RL algorithm in RLlib
"""
Reference: https://github.com/ray-project/ray/blob/f8a91c7fad248b1c7f81fd6d30191ac930a92bc4/rllib/examples/env/simple_corridor.py
Fixes:
ValueError: ('Observation ({}) outside given space ({})!', array([0.]), Box([0.], [999.], (1,), float32))
"""
import gym
from gym.spaces import Box, Discrete
import numpy as np
@rlan
rlan / merge_callbacks.py
Created April 27, 2021 04:14
Merge callbacks for any number of DefaultCallbacks classes in RLlib
from typing import Dict, List, Optional, TYPE_CHECKING
from ray.rllib.agents.callbacks import DefaultCallbacks
from ray.rllib.env import BaseEnv
from ray.rllib.policy import Policy
from ray.rllib.policy.sample_batch import SampleBatch
from ray.rllib.evaluation import MultiAgentEpisode
from ray.rllib.utils.annotations import PublicAPI
from ray.rllib.utils.deprecation import deprecation_warning
from ray.rllib.utils.typing import AgentID, PolicyID
@rlan
rlan / python_venv_ubuntu_20.04.md
Last active September 17, 2020 05:19
How to create a Python virtual environment on Ubuntu 20.04

Ubuntu 20.04 uses python 3.8.

Install virtual environment tool:

sudo apt update
sudo apt install python3-venv

Create a virtual environment for Python: