|
Download README.md from chan20/model: direct link, hf CLI and curl.
- Browser
- Download file 1.84 kB
-
https://huggingface.co/chan20/model/resolve/main/README.md
- Command line
-
hf download hf://chan20/model/README.md
-
curl -L -o README.md https://huggingface.co/chan20/model/resolve/main/README.md
1.84 kB
| tags: | |
| - pytorch | |
| - tabular-classification | |
| - synthetic-data | |
| library_name: pytorch | |
| # Simple Feed-Forward Neural Network | |
| This is a simple PyTorch feed-forward neural network trained on synthetic data. | |
| ## Model Details | |
| - **Architecture**: Feed-forward Neural Network | |
| - **Input Size**: 10 features | |
| - **Hidden Layer**: 32 neurons with ReLU activation | |
| - **Output Layer**: 2 classes (Binary Classification) | |
| - **Framework**: PyTorch | |
| ## Training Data | |
| The model was trained on 1000 samples of synthetic data generated using `torch.randn`. | |
| - **Features**: 10 random float values per sample. | |
| - **Labels**: Binary (0 or 1), randomly assigned. | |
| - **Split**: 80% Training, 20% Testing. | |
| ## Training Procedure | |
| - **Optimizer**: Adam | |
| - **Loss Function**: CrossEntropyLoss | |
| - **Batch Size**: 32 | |
| - **Epochs**: 20 | |
| ## Usage | |
| ### Installation | |
| ```bash | |
| pip install torch | |
| ``` | |
| ### Inference Code | |
| ```python | |
| import torch | |
| import torch.nn as nn | |
| import json | |
| # Define Model Architecture | |
| class SimpleNN(nn.Module): | |
| def __init__(self, input_size, hidden_size, output_size): | |
| super(SimpleNN, self).__init__() | |
| self.fc1 = nn.Linear(input_size, hidden_size) | |
| self.relu = nn.ReLU() | |
| self.fc2 = nn.Linear(hidden_size, output_size) | |
| def forward(self, x): | |
| out = self.fc1(x) | |
| out = self.relu(out) | |
| out = self.fc2(out) | |
| return out | |
| # Load Configuration | |
| with open("config.json", "r") as f: | |
| config = json.load(f) | |
| # Load Model | |
| model = SimpleNN(config["input_size"], config["hidden_size"], config["output_size"]) | |
| model.load_state_dict(torch.load("model.pth")) | |
| model.eval() | |
| # Predict | |
| dummy_input = torch.randn(1, 10) | |
| output = model(dummy_input) | |
| _, prediction = torch.max(output, 1) | |
| print(f"Prediction: {prediction.item()}") | |
| ``` | |