
![]() |
@wtf | |
PyTorch/ Tensorflow Deep Learning Frameworks |
||
1
Replies
23
Views
1 Bookmarks
|
![]() |
@wtf | 8 August 25 |
PyTorch is a popular open-source machine learning library developed by Facebook, widely used for deep learning and research. Why Use PyTorch? Dynamic computation graph (eager execution) Easy to debug and experiment with Strong GPU acceleration (via CUDA) Deep integration with Python ecosystem Huge support in academia and production Installation bash pip install torch torchvision torchaudio Basic Example: Simple Neural Network python import torch import torch.nn as nn import torch.optim as optim Dummy input/output X = torch.randn(10, 3) y = torch.randn(10, 1) Define model model = nn.Linear(3, 1) loss_fn = nn.MSELoss() optimizer = optim.SGD(model.parameters(), lr=0.01) Train loop for epoch in range(100): y_pred = model(X) loss = loss_fn(y_pred, y) optimizer.zero_grad() loss.backward() optimizer.step() Common Use Cases Image classification Natural Language Processing (NLP) Generative models (GANs, VAEs) Reinforcement Learning TensorFlow, developed by Google, is a powerful framework for building and deploying machine learning models at scale. Why Use TensorFlow? High performance on large-scale ML tasks Built-in support for production deployment TensorBoard for visualization Compatible with Keras (high-level API) Extensive community & resources Installation bash pip install tensorflow Basic Example (Using Keras API) python import tensorflow as tf from tensorflow import keras from tensorflow.keras import layers Define model model = keras.Sequential([ layers.Dense(64, activation='relu'), layers.Dense(1) ]) Compile model model.compile(optimizer='adam', loss='mse') Dummy data X = tf.random.normal((10, 3)) y = tf.random.normal((10, 1)) Train model model.fit(X, y, epochs=10) Common Use Cases Deep learning at scale Mobile/Edge deployment (TF Lite) Time series, NLP, Computer Vision Model serving (TF Serving) |
||


