Skip to content
Home Tutorials Roadmaps Courses
Log in Join free
Tutorials AI TensorFlow & PyTorch
AI Intermediate FREE

TensorFlow & PyTorch

Lesson 1 of 17 Intermediate Interactive

TensorFlow and PyTorch are the two most popular deep learning frameworks.

Syntax

AI
# TensorFlow
import tensorflow as tf
model = tf.keras.Sequential([...])

# PyTorch
import torch
model = torch.nn.Sequential([...])
PyTorch Tensor Basics
PYTHON
# PyTorch tensor operations (conceptual)
# import torch

# Simulated tensor operations
def matmul(a, b):
    rows_a, cols_a = len(a), len(a[0])
    cols_b = len(b[0])
    result = [[0] * cols_b for _ in range(rows_a)]
    for i in range(rows_a):
        for j in range(cols_b):
            for k in range(cols_a):
                result[i][j] += a[i][k] * b[k][j]
    return result

A = [[1, 2], [3, 4]]
B = [[5, 6], [7, 8]]
C = matmul(A, B)
print("Matrix multiplication:")
for row in C:
    print(row)