{ "cells": [ { "cell_type": "markdown", "id": "88d5f7fd-e30e-474e-ab44-01dbed16fd70", "metadata": { "tags": [] }, "source": [ "# Compatibility with Pytorch" ] }, { "cell_type": "code", "execution_count": 1, "id": "8b74ef1e-4753-449a-9e10-7cb3d25c2b7d", "metadata": { "tags": [] }, "outputs": [], "source": [ "import torch\n", "import numpy as np\n", "import stackview" ] }, { "cell_type": "code", "execution_count": 2, "id": "0eba88e8-c6da-4b36-a8be-4095652c9e53", "metadata": { "tags": [] }, "outputs": [], "source": [ "image = np.random.random((100,100))" ] }, { "cell_type": "code", "execution_count": 3, "id": "74ae019e-78df-4958-8396-22d20ca6e059", "metadata": { "tags": [] }, "outputs": [], "source": [ "tensor = torch.tensor(image)" ] }, { "cell_type": "code", "execution_count": 4, "id": "ffe39017-c92f-4742-991d-b479cb7354e6", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "\n", "\n", "
\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "\n", "
shape(100, 100)
dtypefloat64
size78.1 kB
min6.298328163456546e-07
max0.9998952325966913
\n", "\n", "
" ], "text/plain": [ "StackViewNDArray([[0.37240883, 0.51519728, 0.9798847 , ..., 0.49030327,\n", " 0.38611394, 0.95076258],\n", " [0.42237922, 0.22634778, 0.60843972, ..., 0.96904272,\n", " 0.66522756, 0.47810218],\n", " [0.11432476, 0.22070185, 0.8272397 , ..., 0.8742889 ,\n", " 0.39443865, 0.07895157],\n", " ...,\n", " [0.37055074, 0.96540217, 0.27170109, ..., 0.09015231,\n", " 0.72701669, 0.48951788],\n", " [0.099454 , 0.68272063, 0.14435829, ..., 0.41993742,\n", " 0.65495363, 0.58525335],\n", " [0.18358879, 0.71309265, 0.89412093, ..., 0.6198881 ,\n", " 0.23823675, 0.78411111]])" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stackview.insight(tensor)" ] }, { "cell_type": "code", "execution_count": null, "id": "ef68d563-3c4c-4201-a27b-b96674e970b5", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.16" } }, "nbformat": 4, "nbformat_minor": 5 }