Create README.MD
Browse files
README.MD
ADDED
@@ -0,0 +1,77 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Model Deployment Guide
|
2 |
+
|
3 |
+
This project contains the necessary files to deploy a machine learning model using Keras. Below is a description of each file and how to use them.
|
4 |
+
This documentation provides detailed information about the machine learning model, its architecture, configuration, and how to use it for predictions. The model has been built using Keras and TensorFlow and is saved in a modular format with separate files for configuration, metadata, and weights.
|
5 |
+
1. config.json
|
6 |
+
Purpose: This file describes the architecture of the Keras model.
|
7 |
+
• Contains the layer configurations, including input, embedding, LSTM, and output layers.
|
8 |
+
• Specifies the model type: Sequential or Functional.
|
9 |
+
• Includes optimizer, loss function, and training parameters.
|
10 |
+
Example details from config.json:
|
11 |
+
• Input Shape: [batch_size, sequence_length]
|
12 |
+
• Layers:
|
13 |
+
o Input Layer
|
14 |
+
o Embedding Layer (Input Dimension: 13745, Output Dimension: 512)
|
15 |
+
o LSTM Layers
|
16 |
+
o TimeDistributed Dense Output Layer
|
17 |
+
2. metadata.json
|
18 |
+
Purpose: Metadata about the model.
|
19 |
+
• Keras Version: 3.4.1
|
20 |
+
• Date Saved:
|
21 |
+
o First model: 2024-11-15 11:24:05
|
22 |
+
o Second model: 2024-11-15 11:38:25
|
23 |
+
3. model.weights.h5
|
24 |
+
Purpose: Contains the trained weights of the model.
|
25 |
+
• Must be used in combination with the architecture defined in config.json to reconstruct the model.
|
26 |
+
Ensure the following dependencies are installed:
|
27 |
+
• Python 3.8 or later
|
28 |
+
• TensorFlow 2.10 or later
|
29 |
+
• Keras 3.4.1 or later
|
30 |
+
|
31 |
+
|
32 |
+
## Files in the Repository
|
33 |
+
|
34 |
+
### 1. `config.json`
|
35 |
+
This file contains the configuration of the Keras model. It defines the architecture, including input layers, embedding layers, LSTMs, and the output layer. Key details include:
|
36 |
+
- **Model Type**: Sequential/Functional
|
37 |
+
- **Layers**: InputLayer, Embedding, LSTM, RepeatVector, TimeDistributed
|
38 |
+
- **Optimizer**: Adam
|
39 |
+
- **Loss Function**: Sparse Categorical Crossentropy
|
40 |
+
|
41 |
+
### 2. `metadata.json`
|
42 |
+
This file contains metadata about the model:
|
43 |
+
- **Keras Version**: 3.4.1
|
44 |
+
- **Date Saved**: 2024-11-15
|
45 |
+
|
46 |
+
### 3. `model.weights.h5`
|
47 |
+
This file contains the trained weights of the model. It should be loaded alongside the model configuration to make predictions.
|
48 |
+
|
49 |
+
## How to Use
|
50 |
+
|
51 |
+
### Prerequisites
|
52 |
+
- Python 3.8 or later
|
53 |
+
- TensorFlow 2.10 or later
|
54 |
+
- Keras 3.4.1 or later
|
55 |
+
|
56 |
+
### Steps
|
57 |
+
1. **Setup Environment**:
|
58 |
+
```bash
|
59 |
+
pip install tensorflow keras
|
60 |
+
from tensorflow.keras.models import model_from_json
|
61 |
+
|
62 |
+
# Load model configuration
|
63 |
+
with open('config.json', 'r') as json_file:
|
64 |
+
model_config = json_file.read()
|
65 |
+
|
66 |
+
model = model_from_json(model_config)
|
67 |
+
|
68 |
+
# Load weights
|
69 |
+
model.load_weights('model.weights.h5')
|
70 |
+
from tensorflow.keras.optimizers import Adam
|
71 |
+
|
72 |
+
model.compile(
|
73 |
+
optimizer=Adam(learning_rate=0.001),
|
74 |
+
loss='sparse_categorical_crossentropy'
|
75 |
+
)
|
76 |
+
predictions = model.predict(input_data)
|
77 |
+
|