Skip to content

Commit

Permalink
Create nnpm.py
Browse files Browse the repository at this point in the history
  • Loading branch information
KOSASIH authored Jul 15, 2024
1 parent 803152b commit e2d8b33
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions models/nnpm/nnpm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import torch
import torch.nn as nn
import torch.optim as optim

class NNPM(nn.Module):
def __init__(self):
super(NNPM, self).__init__()
self.fc1 = nn.Linear(128, 256) # Input layer (128) -> Hidden layer (256)
self.fc2 = nn.Linear(256, 128) # Hidden layer (256) -> Output layer (128)

def forward(self, x):
x = torch.relu(self.fc1(x)) # Activation function for hidden layer
x = self.fc2(x)
return x

model = NNPM()
criterion = nn.MSELoss()
optimizer = optim.Adam(model.parameters(), lr=0.001)

# Train the model
for epoch in range(100):
optimizer.zero_grad()
outputs = model(inputs)
loss = criterion(outputs, labels)
loss.backward()
optimizer.step()
print(f'Epoch {epoch+1}, Loss: {loss.item()}')

# Use the trained model for predictive maintenance
def predict_maintenance(inputs):
outputs = model(inputs)
return outputs

0 comments on commit e2d8b33

Please sign in to comment.