Views
No views yet
Input Layer: 9 features
Hidden Layer 1: 64 neurons (ReLU + BatchNorm + Dropout 0.3)
Hidden Layer 2: 32 neurons (ReLU + BatchNorm + Dropout 0.2)
Hidden Layer 3: 16 neurons (ReLU + Dropout 0.1)
Output Layer: 3 neurons (Softmax)1// Load the model
2const model = await tf.loadLayersModel('model.json');
3
4// Prepare input (9-dimensional array)
5const gameState = tf.tensor2d([[
6 lane0_near, lane0_far, // Lane 0 sensors
7 lane1_near, lane1_far, // Lane 1 sensors
8 lane2_near, lane2_far, // Lane 2 sensors
9 current_lane_norm, // Current lane (0-1)
10 progress_norm, // Game progress (0-1)
11 speed_factor // Speed factor
12]], [1, 9]);
13
14// Get prediction
15const prediction = model.predict(gameState);
16const actionProbs = await prediction.data();
17
18// Choose action (0=Left, 1=Stay, 2=Right)
19const action = actionProbs.indexOf(Math.max(...actionProbs));1import tensorflow as tf
2import numpy as np
3
4# Load the model
5model = tf.keras.models.load_model('racing_model.keras')
6
7# Prepare input
8game_state = np.array([[
9 lane0_near, lane0_far,
10 lane1_near, lane1_far,
11 lane2_near, lane2_far,
12 current_lane_norm,
13 progress_norm,
14 speed_factor
15]])
16
17# Get prediction
18action_probs = model.predict(game_state)[0]
19action = np.argmax(action_probs) # 0=Left, 1=Stay, 2=Rightmodel.json + *.bin: TensorFlow.js model filesracing_model.keras: Native Keras modelmetadata.json: Model metadata and training infotraining_history.png: Training progress visualization1@misc{ai_racing_model,
2 title={AI Racing Game Neural Network},
3 author={Your Name},
4 year={2025},
5 publisher={Hugging Face},
6 url={https://huggingface.co/Relacosm/theline-v1}
7}