https://github.com/asmi-va/ai_car_simulator-model-

https://github.com/asmi-va/ai_car_simulator-model-

Science Score: 13.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
  • DOI references
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (12.0%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

Basic Info
  • Host: GitHub
  • Owner: Asmi-va
  • Language: Python
  • Default Branch: main
  • Size: 7.81 KB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 0
Created almost 2 years ago · Last pushed almost 2 years ago
Metadata Files
Readme

README.md

aicarsimulator-model-

Here's a README file for your Deep Q Learning implementation:


Deep Q Learning

This repository contains an implementation of Deep Q Learning using PyTorch. The code includes a neural network for approximating Q-values, experience replay for training stability, and mechanisms for saving and loading model checkpoints.

Overview

Components

  1. Neural Network (Network)

    • A simple feedforward neural network with one hidden layer.
    • Input layer to hidden layer: 30 neurons.
    • Hidden layer to output layer: Number of actions.
  2. Experience Replay (ExperienceReplay)

    • Stores and manages past experiences to improve training stability.
    • Allows sampling of random batches of experiences for training.
  3. Deep Q Learning (DeepQNetwork)

    • Manages training and decision-making processes.
    • Utilizes the neural network and experience replay to learn optimal policies.
    • Includes methods for action selection, learning from experiences, and model saving/loading.

Installation

Ensure you have the required libraries installed:

bash pip install numpy torch

Usage

  1. Initialize the Deep Q Network:

python dqn = DeepQNetwork(input_size=4, number_of_actions=2, gamma=0.99)

  • input_size: Number of features in the state.
  • number_of_actions: Number of possible actions.
  • gamma: Discount factor for future rewards.
  1. Updating the Model:
  • Call update(reward, new_signal) after each step to update the model with new experiences.

python action = dqn.update(reward=1.0, new_signal=[1, 0, 0, 1])

  1. Saving and Loading Models:
  • To save the model:

    python dqn.save()

  • To load a saved model:

    python dqn.load()

  1. Scoring the Model:
  • To get the average score:

    python average_score = dqn.score()

Code Overview

  • Network Class: Defines the neural network architecture.
  • ExperienceReplay Class: Manages the replay buffer.
  • DeepQNetwork Class: Implements Deep Q Learning algorithm with methods for action selection, learning, and model management.

Example Code

Here's a snippet showing how to use the DeepQNetwork class:

```python import torch

Initialize DeepQNetwork

dqn = DeepQNetwork(inputsize=4, numberof_actions=2, gamma=0.99)

Simulate an experience

reward = 1.0 new_signal = [1, 0, 0, 1]

Update the model

action = dqn.update(reward=reward, newsignal=newsignal)

Save the model

dqn.save()

Load the model

dqn.load()

Get the average score

averagescore = dqn.score() print(f"Average Score: {averagescore}") ```

License

This project is open-source and free to use. You may use, modify, and distribute it as you see fit.


Owner

  • Name: asmi
  • Login: Asmi-va
  • Kind: user

GitHub Events

Total
Last Year