# AIET Training and Inference Models

## Model Training

### Definition:

&#x20;Model training refers to the process of using a large amount of data to train artificial intelligence algorithms, enabling the model to learn patterns and features within the data. This process involves adjusting the parameters of the model, such as weights and biases, to minimize prediction errors.

### Code Example:&#x20;

Here is a simple example of neural network model training:

```
import torch
import torch.nn as nn
import torch.optim as optim

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.fc1 = nn.Linear(10, 5) 
        self.fc2 = nn.Linear(5, 2)  

    def forward(self, x):
        x = torch.relu(self.fc1(x))
        x = self.fc2(x)
        return x

net = Net()
optimizer = optim.SGD(net.parameters(), lr=0.01)
criterion = nn.CrossEntropyLoss()


inputs = torch.randn(1, 10)  
targets = torch.tensor([1])  

optimizer.zero_grad()        
outputs = net(inputs)       
loss = criterion(outputs, targets)  
loss.backward()             
optimizer.step()             

```

## Model Inference

### &#x20;Definition:

&#x20;Model inference is the process of using a trained model to make predictions on new data. This step typically does not involve adjusting model parameters; rather, it involves using the model for prediction.

### Code Example:&#x20;

An example of using the trained model for inference:

```
new_inputs = torch.randn(1, 10)  

net.eval() 
with torch.no_grad():
    predictions = net(new_inputs)
    predicted_class = torch.argmax(predictions, dim=1)
    print(f"Predicted class: {predicted_class.item()}")

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://aiet.gitbook.io/aietnet/aiet-training-and-inference-models.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
