{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "/opt/conda/lib/python3.9/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n" ] } ], "source": [ "import torch" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "probability_matrix = torch.full((8, 15), 0.15)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "torch.Size([8, 15])" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "probability_matrix.shape" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "tensor([[0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500,\n", " 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500],\n", " [0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500,\n", " 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500],\n", " [0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500,\n", " 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500],\n", " [0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500,\n", " 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500],\n", " [0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500,\n", " 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500],\n", " [0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500,\n", " 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500],\n", " [0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500,\n", " 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500],\n", " [0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500,\n", " 0.1500, 0.1500, 0.1500, 0.1500, 0.1500, 0.1500]])" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "probability_matrix.masked_fill_(torch.tensor(0, dtype=torch.bool), value=0.0)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "masked_indices = torch.bernoulli()" ] } ], "metadata": { "kernelspec": { "display_name": "base", "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.9.12" }, "orig_nbformat": 4 }, "nbformat": 4, "nbformat_minor": 2 }