cajcodes commited on
Commit
ba4ed85
·
verified ·
1 Parent(s): 2d9b3f8

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +118 -0
README.md ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ tags:
4
+ - deep-q-network
5
+ - reinforcement-learning
6
+ - pathfinding
7
+ - hospital-floorplan
8
+ license: apache-2.0
9
+ datasets:
10
+ - custom
11
+ metrics:
12
+ - average_reward
13
+ - success_rate
14
+ ---
15
+
16
+ # Deep Q-Network for Hospital Floorplan Navigation
17
+
18
+ ## Model Description
19
+
20
+ This model is a Deep Q-Network (DQN) designed to find the most efficient path through a hospital floorplan for wheeling a bed without hitting obstacles. The model combines traditional pathfinding algorithms with reinforcement learning for optimal performance.
21
+
22
+ ## Model Architecture
23
+
24
+ The model is a fully connected neural network with the following architecture:
25
+ - Input Layer: Flattened grid representation of the floorplan
26
+ - Hidden Layers: Two hidden layers with 64 units each and ReLU activation
27
+ - Output Layer: Four units representing the possible actions (up, down, left, right)
28
+
29
+ ## Training
30
+
31
+ The model was trained using a hybrid approach:
32
+ 1. **A* Algorithm**: Initially, the A* algorithm was used to find the shortest path in a static environment.
33
+ 2. **Reinforcement Learning**: The DQN was trained with guidance from the A* path to improve efficiency and adaptability.
34
+
35
+ ### Hyperparameters
36
+ - Learning Rate: 0.001
37
+ - Batch Size: 64
38
+ - Gamma (Discount Factor): 0.99
39
+ - Target Update Frequency: Every 100 episodes
40
+ - Number of Episodes: 50
41
+
42
+ ## Usage
43
+
44
+ To use this model, load the saved state dictionary and initialize the DQN with the same architecture. The model can then be used to navigate a hospital floorplan and find the most efficient path to the target.
45
+
46
+ ### Example Code
47
+
48
+ ```python
49
+ import torch
50
+
51
+ # Define the DQN class (same as in the training script)
52
+ class DQN(nn.Module):
53
+ def __init__(self, input_size, hidden_sizes, output_size):
54
+ super(DQN, self).__init__()
55
+ self.input_size = input_size
56
+ self.hidden_sizes = hidden_sizes
57
+ self.output_size = output_size
58
+
59
+ self.fc_layers = nn.ModuleList()
60
+ prev_size = input_size
61
+ for size in hidden_sizes:
62
+ self.fc_layers.append(nn.Linear(prev_size, size))
63
+ prev_size = size
64
+ self.output_layer = nn.Linear(prev_size, output_size)
65
+
66
+ def forward(self, x):
67
+ if len(x.shape) > 2:
68
+ x = x.view(x.size(0), -1)
69
+ for layer in self.fc_layers:
70
+ x = F.relu(layer(x))
71
+ x = self.output_layer(x)
72
+ return x
73
+
74
+ # Load the model
75
+ input_size = 100 # 10x10 grid flattened
76
+ hidden_sizes = [64, 64]
77
+ output_size = 4
78
+ model = DQN(input_size, hidden_sizes, output_size)
79
+ model.load_state_dict(torch.load('dqn_model.pth'))
80
+ model.eval()
81
+
82
+ # Use the model for inference (example state)
83
+ state = ... # Define your state here
84
+ with torch.no_grad():
85
+ action = model(torch.tensor(state, dtype=torch.float32).unsqueeze(0)).argmax().item()
86
+ ```
87
+ ## Evaluation
88
+
89
+ The model was evaluated based on:
90
+
91
+ - Average Reward: The mean reward over several episodes
92
+ - Success Rate: The proportion of episodes where the agent successfully reached the target
93
+
94
+ ## Initial Evaluation Results
95
+ - Average Reward: 8.84
96
+ - Success Rate: 1.0
97
+
98
+ ## Limitations
99
+
100
+ - The model's performance can be influenced by the complexity of the floorplan and the density of obstacles.
101
+ - It requires a grid-based representation of the environment for accurate navigation.
102
+
103
+ ## Acknowledgements
104
+
105
+ This project leverages the power of reinforcement learning combined with traditional pathfinding algorithms to navigate complex environments efficiently.
106
+
107
+ ## Citation
108
+
109
+ If you use this model in your research, please cite it as follows:
110
+ ```
111
+ @misc{jones2024dqnhospital,
112
+ author = {Christopher Jones},
113
+ title = {Deep Q-Network for Floorplan Navigation},
114
+ year = {2024},
115
+ howpublished = {\url{https://huggingface.co/cajcodes/dqn-hospital-floorplan}},
116
+ note = {Accessed: YYYY-MM-DD}
117
+ }
118
+ ```