Downloads · 30 days
11
24% of all-time downloads
kbsooo/AlphaApple
AlphaApple is a reinforcement learning model from kbsooo. Use it for the reinforcement learning task on the model card, and read the license before you ship it in a product. It is set up for pytorch.
This model plays the FruitBox (Fruit Box) puzzle game hosted on Gamesaien. It predicts Q-values over all axis-aligned rectangles on a 10x17 board. A valid action is a rectangle whose cell sum is exactly 10, so you mus…
Downloads · 30 days
11
24% of all-time downloads
All-time downloads
45
Public
Repo size
211 MB
Likes
0
Public
Click a slice to open those files.
.pth159 MB · 80%
From the Hugging Face model README
This model plays the FruitBox (Fruit Box) puzzle game hosted on Gamesaien. It predicts Q-values over all axis-aligned rectangles on a 10x17 board. A valid action is a rectangle whose cell sum is exactly 10, so you must apply an action mask to filter invalid rectangles before selecting the best move.
[1, 10, 10, 17]model.pth: PyTorch checkpoint dict with policy_net, target_net, optimizermodel.onnx: Exported ONNX model for browser/runtime inference# Model definition is in https://github.com/kbsooo/AlphaApple (src/models.py)
import torch
from src.models import FruitBoxDQN
rows, cols = 10, 17
n_actions = 55 * 153 # (rows*(rows+1)/2) * (cols*(cols+1)/2) = 8415
model = FruitBoxDQN(rows, cols, n_actions)
ckpt = torch.load("model.pth", map_location="cpu")
state = ckpt["policy_net"] if "policy_net" in ckpt else ckpt
model.load_state_dict(state)
model.eval()
const session = await ort.InferenceSession.create("model.onnx");
// input: Float32Array with shape [1, 10, 10, 17]
const output = await session.run({ input });
// output.output.data: Q-values for 8415 rectangles
You must mask invalid rectangles before selecting an action. A rectangle is valid if the sum of its cells equals 10. Without the mask, the model can pick illegal moves.
envs/fruitbox_env.py, class FruitBoxEnvImproved)