{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "# Tensor Operations in PyTorch\n",
        "\n",
        "<!--\n",
        "Project: PyTorch Neural Networks\n",
        "Author: RSK World\n",
        "Website: https://rskworld.in\n",
        "Email: help@rskworld.in\n",
        "Phone: +91 93305 39277\n",
        "-->\n",
        "\n",
        "This notebook demonstrates basic tensor operations in PyTorch, the foundation of all neural network computations.\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Tensor Operations in PyTorch\n",
        "# Project: PyTorch Neural Networks\n",
        "# Author: RSK World\n",
        "# Website: https://rskworld.in\n",
        "# Email: help@rskworld.in\n",
        "# Phone: +91 93305 39277\n",
        "\n",
        "import torch\n",
        "import numpy as np\n",
        "\n",
        "print(f\"PyTorch version: {torch.__version__}\")\n",
        "print(f\"CUDA available: {torch.cuda.is_available()}\")\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Creating Tensors\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Create tensors from lists\n",
        "t1 = torch.tensor([1, 2, 3, 4, 5])\n",
        "print(f\"Tensor from list: {t1}\")\n",
        "\n",
        "# Create tensors with zeros\n",
        "t2 = torch.zeros(3, 4)\n",
        "print(f\"\\nZero tensor (3x4):\\n{t2}\")\n",
        "\n",
        "# Create tensors with ones\n",
        "t3 = torch.ones(2, 3)\n",
        "print(f\"\\nOnes tensor (2x3):\\n{t3}\")\n",
        "\n",
        "# Create random tensor\n",
        "t4 = torch.randn(2, 3)\n",
        "print(f\"\\nRandom tensor (2x3):\\n{t4}\")\n",
        "\n",
        "# Create tensor with specific range\n",
        "t5 = torch.arange(0, 10, 2)\n",
        "print(f\"\\nArange tensor: {t5}\")\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## Tensor Operations\n",
        "\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# Basic arithmetic operations\n",
        "a = torch.tensor([1.0, 2.0, 3.0])\n",
        "b = torch.tensor([4.0, 5.0, 6.0])\n",
        "\n",
        "print(f\"Addition: {a + b}\")\n",
        "print(f\"Subtraction: {a - b}\")\n",
        "print(f\"Multiplication: {a * b}\")\n",
        "print(f\"Division: {b / a}\")\n",
        "\n",
        "# Matrix multiplication\n",
        "x = torch.randn(3, 4)\n",
        "y = torch.randn(4, 5)\n",
        "z = torch.matmul(x, y)\n",
        "print(f\"\\nMatrix multiplication result shape: {z.shape}\")\n",
        "\n",
        "# Element-wise operations\n",
        "print(f\"\\nSum: {a.sum()}\")\n",
        "print(f\"Mean: {a.mean()}\")\n",
        "print(f\"Max: {a.max()}\")\n",
        "print(f\"Min: {a.min()}\")\n",
        "\n"
      ]
    }
  ],
  "metadata": {
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 2
}
