ML Study Guide
ML Study Guide
### Keras
2. Key Components:
`model.predict`.
3. Important Layers:
4. Example Code:
```python
model = Sequential([
Flatten(),
Dense(128, activation='relu'),
Dropout(0.5),
Dense(10, activation='softmax')
])
model.compile(optimizer='adam', loss='categorical_crossentropy',
metrics=['accuracy'])
```
### PyTorch
2. Key Components:
3. Example Code:
```python
import torch
import torch.nn as nn
class SimpleNN(nn.Module):
def __init__(self):
super(SimpleNN, self).__init__()
self.relu = nn.ReLU()
x = self.relu(self.fc1(x))
x = self.fc2(x)
return x
model = SimpleNN()
criterion = nn.CrossEntropyLoss()
```
1. **Ease of Use**: Keras is simpler for quick prototyping; PyTorch offers more
flexibility.
Python debuggers.