Run this model with HF Jobs
Run ShaswatRobotics/world_model_test on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/ShaswatRobotics/world_model_test. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/ShaswatRobotics/world_model_test on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use ShaswatRobotics/world_model_test with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- TF-Keras
How to use ShaswatRobotics/world_model_test with TF-Keras:
# Note: 'keras<3.x' or 'tf_keras' must be installed (legacy), and from_pretrained_keras was removed in huggingface_hub 1.0. # See https://github.com/keras-team/tf-keras for more details. # !pip install "huggingface_hub<1.0" tf_keras from huggingface_hub import from_pretrained_keras model = from_pretrained_keras("ShaswatRobotics/world_model_test") - Notebooks
- Google Colab
- Kaggle
Upload 4 files
Browse filesFiles changed (4)
123version https://git-lfs.github.com/spec/v1oid sha256:3ae346f29cece02fefdc82310919c046f5c930a3eb165a5f521dfccbd1388154size 407381123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113"""generate_random_wm.py
Creates random (but valid) world-model networks:- Encoder- Transition model- Reward model
Saves class-compatible state_dict weights."""
import osimport torchimport torch.nn as nnimport torch.nn.functional as F
# -------------------------# Config (Ant-style)# -------------------------OBS_DIM = 105ACTION_DIM = 8LATENT_DIM = 32HIDDEN_DIM = 256SEED = 42
OUT_DIR = "weights"
# -------------------------# Models# -------------------------class Encoder(nn.Module): def __init__(self, obs_dim: int, latent_dim: int, hidden_dim: int): super().__init__() self.net = nn.Sequential( nn.Linear(obs_dim, hidden_dim), nn.ReLU(), nn.Linear(hidden_dim, hidden_dim), nn.ReLU(), nn.Linear(hidden_dim, latent_dim), )
def forward(self, obs): return self.net(obs)
class TransitionModel(nn.Module): def __init__(self, latent_dim: int, action_dim: int, hidden_dim: int): super().__init__() self.net = nn.Sequential( nn.Linear(latent_dim + action_dim, hidden_dim), nn.ReLU(), nn.Linear(hidden_dim, hidden_dim), nn.ReLU(), nn.Linear(hidden_dim, latent_dim), )
def forward(self, z, action): x = torch.cat([z, action], dim=-1) return self.net(x)
class RewardModel(nn.Module): def __init__(self, latent_dim: int, action_dim: int, hidden_dim: int): super().__init__() self.net = nn.Sequential( nn.Linear(latent_dim + action_dim, hidden_dim), nn.ReLU(), nn.Linear(hidden_dim, 1), )
def forward(self, z, action): x = torch.cat([z, action], dim=-1) return self.net(x).squeeze(-1)
# -------------------------# Initialization# -------------------------def init_weights(m): if isinstance(m, nn.Linear): nn.init.orthogonal_(m.weight) nn.init.zeros_(m.bias)
# -------------------------# Main# -------------------------def main(): torch.manual_seed(SEED)
encoder = Encoder(OBS_DIM, LATENT_DIM, HIDDEN_DIM) transition = TransitionModel(LATENT_DIM, ACTION_DIM, HIDDEN_DIM) reward = RewardModel(LATENT_DIM, ACTION_DIM, HIDDEN_DIM)
encoder.apply(init_weights) transition.apply(init_weights) reward.apply(init_weights)
os.makedirs(OUT_DIR, exist_ok=True)
torch.save(encoder.state_dict(), f"{OUT_DIR}/encoder.pth") torch.save(transition.state_dict(), f"{OUT_DIR}/transition.pth") torch.save(reward.state_dict(), f"{OUT_DIR}/reward.pth")
print("✅ Random world-model weights saved:") print(f" {OUT_DIR}/encoder.pth") print(f" {OUT_DIR}/transition.pth") print(f" {OUT_DIR}/reward.pth")
if __name__ == "__main__": main()123version https://git-lfs.github.com/spec/v1oid sha256:ad796e55dfaebcba46a0baaec334c8e996794aace6950df447e6168f735426absize 45331123version https://git-lfs.github.com/spec/v1oid sha256:cd055e79288d6f6d3e10d83dab550a1dfb843261d44b7af029b6c7b5d4d4e5cdsize 341177ant/pwm_torch_seperate/encoder.pthAdded+3
ant/pwm_torch_seperate/random_torch.pyAdded+113
ant/pwm_torch_seperate/reward.pthAdded+3
ant/pwm_torch_seperate/transition.pthAdded+3