{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "#### uniform stochastic depth" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "24\n", "25\n", "[0.0, 0.004347826354205608, 0.008695652708411217, 0.013043479062616825, 0.017391305416822433, 0.021739132702350616, 0.02608695812523365, 0.030434783548116684, 0.03478261083364487, 0.03913043811917305, 0.04347826540470123, 0.04782608896493912, 0.052173912525177, 0.056521736085414886, 0.06086956337094307, 0.06521739065647125, 0.06956521421670914, 0.07391304522752762, 0.0782608687877655, 0.08260869979858398, 0.08695652335882187, 0.09130434691905975, 0.09565217792987823, 0.10000000149011612]\n" ] } ], "source": [ "import torch\n", "\n", "drop_path_rate = 0.1\n", "depth = 24\n", "\n", "dpr = [x.item() for x in torch.linspace(0, drop_path_rate, depth)]\n", "\n", "print(len(dpr))\n", "inter_dpr = [0.0] + dpr\n", "print(len(inter_dpr))\n", "print(dpr)" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n", "24\n" ] } ], "source": [ "import torch\n", "\n", "drop_path_rate = 0\n", "depth = 24\n", "\n", "dpr = [x.item() for x in torch.full((depth,), drop_path_rate)]\n", "print(dpr)\n", "print(len(dpr))" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "tensor([[[ 0, 1, 2],\n", " [ 3, 4, 5],\n", " [ 6, 7, 8],\n", " [ 9, 10, 11],\n", " [12, 13, 14]],\n", "\n", " [[15, 16, 17],\n", " [18, 19, 20],\n", " [21, 22, 23],\n", " [24, 25, 26],\n", " [27, 28, 29]]])\n", "-------------------------\n", "tensor([[[ 2, 1, 0],\n", " [ 5, 4, 3],\n", " [ 8, 7, 6],\n", " [11, 10, 9],\n", " [14, 13, 12]],\n", "\n", " [[17, 16, 15],\n", " [20, 19, 18],\n", " [23, 22, 21],\n", " [26, 25, 24],\n", " [29, 28, 27]]])\n", "-------------------------\n", "tensor([[[12, 13, 14],\n", " [ 9, 10, 11],\n", " [ 6, 7, 8],\n", " [ 3, 4, 5],\n", " [ 0, 1, 2]],\n", "\n", " [[27, 28, 29],\n", " [24, 25, 26],\n", " [21, 22, 23],\n", " [18, 19, 20],\n", " [15, 16, 17]]])\n" ] } ], "source": [ "import torch\n", "\n", "x = torch.arange(30).view(2, 5, 3)\n", "print(x)\n", "print(\"-------------------------\")\n", "\n", "y = x.flip([-1])\n", "print(y)\n", "print(\"-------------------------\")\n", "\n", "z = x.flip([1])\n", "print(z)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[0, 2, 3, 1]\n", "This is the i: 0\n", "This is the idx: 0\n", "This is the i: 1\n", "This is the idx: 2\n", "This is the i: 2\n", "This is the idx: 3\n", "This is the i: 3\n", "This is the idx: 1\n" ] } ], "source": [ "import random\n", "\n", "indices = [0, 1, 2, 3]\n", "random.shuffle(indices)\n", "\n", "print(indices)\n", "\n", "for i, idx in enumerate(indices):\n", " print(\"This is the i:\", i)\n", " print(\"This is the idx:\", idx)" ] } ], "metadata": { "kernelspec": { "display_name": "mamba", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.14" } }, "nbformat": 4, "nbformat_minor": 2 }