Upload folder using huggingface_hub
Browse files- README.md +76 -1
- config.json +10 -0
- model.pth +3 -0
README.md
CHANGED
|
@@ -1,3 +1,78 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
tags:
|
| 3 |
+
- pytorch
|
| 4 |
+
- tabular-classification
|
| 5 |
+
- synthetic-data
|
| 6 |
+
library_name: pytorch
|
| 7 |
---
|
| 8 |
+
|
| 9 |
+
# Simple Feed-Forward Neural Network
|
| 10 |
+
|
| 11 |
+
This is a simple PyTorch feed-forward neural network trained on synthetic data.
|
| 12 |
+
|
| 13 |
+
## Model Details
|
| 14 |
+
|
| 15 |
+
- **Architecture**: Feed-forward Neural Network
|
| 16 |
+
- **Input Size**: 10 features
|
| 17 |
+
- **Hidden Layer**: 32 neurons with ReLU activation
|
| 18 |
+
- **Output Layer**: 2 classes (Binary Classification)
|
| 19 |
+
- **Framework**: PyTorch
|
| 20 |
+
|
| 21 |
+
## Training Data
|
| 22 |
+
|
| 23 |
+
The model was trained on 1000 samples of synthetic data generated using `torch.randn`.
|
| 24 |
+
- **Features**: 10 random float values per sample.
|
| 25 |
+
- **Labels**: Binary (0 or 1), randomly assigned.
|
| 26 |
+
- **Split**: 80% Training, 20% Testing.
|
| 27 |
+
|
| 28 |
+
## Training Procedure
|
| 29 |
+
|
| 30 |
+
- **Optimizer**: Adam
|
| 31 |
+
- **Loss Function**: CrossEntropyLoss
|
| 32 |
+
- **Batch Size**: 32
|
| 33 |
+
- **Epochs**: 20
|
| 34 |
+
|
| 35 |
+
## Usage
|
| 36 |
+
|
| 37 |
+
### Installation
|
| 38 |
+
|
| 39 |
+
```bash
|
| 40 |
+
pip install torch
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
### Inference Code
|
| 44 |
+
|
| 45 |
+
```python
|
| 46 |
+
import torch
|
| 47 |
+
import torch.nn as nn
|
| 48 |
+
import json
|
| 49 |
+
|
| 50 |
+
# Define Model Architecture
|
| 51 |
+
class SimpleNN(nn.Module):
|
| 52 |
+
def __init__(self, input_size, hidden_size, output_size):
|
| 53 |
+
super(SimpleNN, self).__init__()
|
| 54 |
+
self.fc1 = nn.Linear(input_size, hidden_size)
|
| 55 |
+
self.relu = nn.ReLU()
|
| 56 |
+
self.fc2 = nn.Linear(hidden_size, output_size)
|
| 57 |
+
|
| 58 |
+
def forward(self, x):
|
| 59 |
+
out = self.fc1(x)
|
| 60 |
+
out = self.relu(out)
|
| 61 |
+
out = self.fc2(out)
|
| 62 |
+
return out
|
| 63 |
+
|
| 64 |
+
# Load Configuration
|
| 65 |
+
with open("config.json", "r") as f:
|
| 66 |
+
config = json.load(f)
|
| 67 |
+
|
| 68 |
+
# Load Model
|
| 69 |
+
model = SimpleNN(config["input_size"], config["hidden_size"], config["output_size"])
|
| 70 |
+
model.load_state_dict(torch.load("model.pth"))
|
| 71 |
+
model.eval()
|
| 72 |
+
|
| 73 |
+
# Predict
|
| 74 |
+
dummy_input = torch.randn(1, 10)
|
| 75 |
+
output = model(dummy_input)
|
| 76 |
+
_, prediction = torch.max(output, 1)
|
| 77 |
+
print(f"Prediction: {prediction.item()}")
|
| 78 |
+
```
|
config.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"input_size": 10,
|
| 3 |
+
"hidden_size": 32,
|
| 4 |
+
"output_size": 2,
|
| 5 |
+
"num_samples": 1000,
|
| 6 |
+
"batch_size": 32,
|
| 7 |
+
"epochs": 20,
|
| 8 |
+
"learning_rate": 0.001,
|
| 9 |
+
"train_split": 0.8
|
| 10 |
+
}
|
model.pth
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4a16da5e00747f917b8757a449a41e8a9f7f10a0dd83e0bf0929dcb168d7ed36
|
| 3 |
+
size 3913
|