{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "b247863c", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "import math\n", "import torch\n", "from dlsia.core import helpers\n", "from dlsia.core.networks import sms3d\n", "from dlsia.core.networks import baggins\n", "import napari" ] }, { "cell_type": "code", "execution_count": 2, "id": "855a85d5", "metadata": {}, "outputs": [], "source": [ "nets = []\n", "for ii in range(5):\n", " net = sms3d.SMSNetwork3D_from_file(\"3d_%i_2023_06_10_depth_25.pt\"%ii)\n", " nets.append(net.eval())" ] }, { "cell_type": "code", "execution_count": 3, "id": "0acd6f5b", "metadata": {}, "outputs": [], "source": [ "bilbo = baggins.model_baggin(nets, \n", " model_type='classification', \n", " returns_normalized=False,\n", " average_type=\"arithmetic\")" ] }, { "cell_type": "code", "execution_count": 4, "id": "4d662643", "metadata": {}, "outputs": [], "source": [ "data_small = np.load(\"data_small.npy\")" ] }, { "cell_type": "code", "execution_count": 5, "id": "forward-pickup", "metadata": {}, "outputs": [], "source": [ "v = napari.view_image(data_small)" ] }, { "cell_type": "code", "execution_count": null, "id": "blessed-wesley", "metadata": {}, "outputs": [], "source": [ "tdata = torch.Tensor(data_small).unsqueeze(0).unsqueeze(0)" ] }, { "cell_type": "code", "execution_count": null, "id": "educated-family", "metadata": {}, "outputs": [], "source": [ "if runit:\n", " with torch.no_grad():\n", " m,s = bilbo.eval()(tdata, return_std=True)\n", "else:\n", " m = np.load(\"mean_small.npy\")\n", " s = np.load(\"std_small.npy\")" ] }, { "cell_type": "code", "execution_count": null, "id": "subject-british", "metadata": {}, "outputs": [], "source": [ "_ = v.add_image(m.numpy()[0,1])\n", "_ = v.add_image(s.numpy()[0,1])" ] }, { "cell_type": "code", "execution_count": null, "id": "dying-publicity", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "lonely-resource", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "embedded-blackjack", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "dlsia-dev", "language": "python", "name": "dlsia-dev" }, "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.0" } }, "nbformat": 4, "nbformat_minor": 5 }