Made tensorboard aggregator and changed slightly scripts

This commit is contained in:
Vasilis Valatsos 2024-06-13 18:44:38 +02:00
parent dd3c7c814b
commit 0c54298746
13 changed files with 62 additions and 13 deletions

0
LICENSE Normal file → Executable file
View file

0
README.md Normal file → Executable file
View file

0
agent.py Normal file → Executable file
View file

39
aggregator.py Normal file
View file

@ -0,0 +1,39 @@
from glob import glob
import tensorboard_reducer as tbr
from policy import policies
strict_steps=False
overwrite = True
reduce_ops = ("mean", "min", "max")
for policy_name in policies:
print(f"Calculating {policy_name}")
# Define glob pattern to find the directories
input_event_dirs = sorted(glob(f"tnsrbrd/sb3/{policy_name}_[0-9]"))
print(f"Found {input_event_dirs}")
# Define output dir
events_output_dir = f"tnsrbrd/results/{policy_name}"
# Load TB events
events_dict = tbr.load_tb_events(input_event_dirs, strict_steps=False, verbose=True)
# Get number of steps and other params
n_scalars = len(events_dict)
n_steps, n_events = list(events_dict.values())[0].shape
print(f"Loaded {n_events} TensorBoard runs with {n_scalars} scalars and {n_steps} steps each")
print(", ".join(events_dict))
# Reduce events
reduced_events = tbr.reduce_events(events_dict, reduce_ops, verbose=True)
for op in reduce_ops:
print(f"Writing '{op}' reduction to '{events_output_dir}-{op}'")
tbr.write_tb_events(reduced_events, events_output_dir, overwrite)
print(f"Reduction of {policy_name} done.")

0
args.py Normal file → Executable file
View file

0
default_bus_layout.tres Normal file → Executable file
View file

0
icon.svg Normal file → Executable file
View file

Before

Width:  |  Height:  |  Size: 9.1 KiB

After

Width:  |  Height:  |  Size: 9.1 KiB

0
main.py Normal file → Executable file
View file

23
poetry.lock generated Normal file → Executable file
View file

@ -1990,6 +1990,27 @@ files = [
{file = "tensorboard_data_server-0.7.2-py3-none-manylinux_2_31_x86_64.whl", hash = "sha256:ef687163c24185ae9754ed5650eb5bc4d84ff257aabdc33f0cc6f74d8ba54530"},
]
[[package]]
name = "tensorboard-reducer"
version = "0.3.1"
description = "Reduce multiple TensorBoard runs to new event (or CSV) files"
optional = false
python-versions = ">=3.8"
files = [
{file = "tensorboard-reducer-0.3.1.tar.gz", hash = "sha256:4e414d2c84c330e837c0acd728a2f74317d086003e87cb76429a24f082dbf66b"},
{file = "tensorboard_reducer-0.3.1-py2.py3-none-any.whl", hash = "sha256:0196a8ec49b3c4535fe42a13dd5407953622e169985fc0ad5f7528bdfba5afbf"},
]
[package.dependencies]
numpy = ">=1.19"
pandas = ">=1.0.0"
tensorboard = ">=2.0"
tqdm = ">=4.0"
[package.extras]
excel = ["openpyxl"]
test = ["pytest", "pytest-cov", "torch (>=1.6)"]
[[package]]
name = "tifffile"
version = "2024.5.10"
@ -2204,4 +2225,4 @@ files = [
[metadata]
lock-version = "2.0"
python-versions = "^3.11"
content-hash = "2d575ca622be4eb61953716f1811accd9330cdbd4ad0ceee31700058e486e7e6"
content-hash = "130e4f2fe889802eb5d4d17d949cced5e88a8248c0fe9f25faabd232c2647259"

0
policy.py Normal file → Executable file
View file

2
pyproject.toml Normal file → Executable file
View file

@ -4,7 +4,6 @@ version = "0.1.0"
description = "Godot training env for MARL"
authors = ["Vasilis Valatsos <vasilvalat@gmail.com>"]
readme = "README.md"
package-mode = false
[tool.poetry.dependencies]
python = "^3.11"
@ -15,6 +14,7 @@ lz4 = "^4.3.3"
godot-rl = {url = "https://github.com/edbeeching/godot_rl_agents/archive/refs/heads/main.zip"}
pettingzoo = "^1.24.3"
tensorboard = "^2.16.2"
tensorboard-reducer = "^0.3.1"
[build-system]

View file

@ -1,11 +0,0 @@
with import <nixpkgs> {};
mkShell {
NIX_LD_LIBRARY_PATH = lib.makeLibraryPath [
stdenv.cc.cc
];
NIX_LD = lib.fileContents "${stdenv.cc}/nix-support/dynamic-linker";
shellHook = ''
export LD_LIBRARY_PATH=$NIX_LD_LIBRARY_PATH
'';
}

0
stable_baselines3_example.py Normal file → Executable file
View file