File size: 1,844 Bytes
c6d632c
3da4057
 
 
 
 
c6d632c
3da4057
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
---

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()}")

```