|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "completed-question", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "# Hospital 2\n", |
| 9 | + "\n", |
| 10 | + "See hospital.py for full code" |
| 11 | + ] |
| 12 | + }, |
| 13 | + { |
| 14 | + "cell_type": "code", |
| 15 | + "execution_count": 1, |
| 16 | + "id": "cubic-international", |
| 17 | + "metadata": {}, |
| 18 | + "outputs": [], |
| 19 | + "source": [ |
| 20 | + "from hospital import Hospital\n", |
| 21 | + "import nest_asyncio\n", |
| 22 | + "\n", |
| 23 | + "nest_asyncio.apply()" |
| 24 | + ] |
| 25 | + }, |
| 26 | + { |
| 27 | + "cell_type": "code", |
| 28 | + "execution_count": 2, |
| 29 | + "id": "piano-joyce", |
| 30 | + "metadata": {}, |
| 31 | + "outputs": [], |
| 32 | + "source": [ |
| 33 | + "data_location = 'data/hospital2.csv'" |
| 34 | + ] |
| 35 | + }, |
| 36 | + { |
| 37 | + "cell_type": "code", |
| 38 | + "execution_count": 3, |
| 39 | + "id": "complex-direction", |
| 40 | + "metadata": {}, |
| 41 | + "outputs": [], |
| 42 | + "source": [ |
| 43 | + "WEBHOOK_HOST = \"0.0.0.0\"\n", |
| 44 | + "WEBHOOK_PORT = 8062\n", |
| 45 | + "WEBHOOK_BASE = \"\"\n", |
| 46 | + "ADMIN_URL = \"http://hospital1-agent:8061\"\n", |
| 47 | + "\n", |
| 48 | + "agent_config = {\n", |
| 49 | + " \"webhook_host\": WEBHOOK_HOST,\n", |
| 50 | + " \"webhook_port\": WEBHOOK_PORT,\n", |
| 51 | + " \"webhook_base\": WEBHOOK_BASE,\n", |
| 52 | + " \"admin_url\": ADMIN_URL\n", |
| 53 | + "}" |
| 54 | + ] |
| 55 | + }, |
| 56 | + { |
| 57 | + "cell_type": "code", |
| 58 | + "execution_count": 4, |
| 59 | + "id": "thirty-scratch", |
| 60 | + "metadata": {}, |
| 61 | + "outputs": [], |
| 62 | + "source": [ |
| 63 | + "hospital2 = Hospital(agent_config, data_location)" |
| 64 | + ] |
| 65 | + }, |
| 66 | + { |
| 67 | + "cell_type": "markdown", |
| 68 | + "id": "afraid-marijuana", |
| 69 | + "metadata": {}, |
| 70 | + "source": [ |
| 71 | + "## Copy from Researcher" |
| 72 | + ] |
| 73 | + }, |
| 74 | + { |
| 75 | + "cell_type": "code", |
| 76 | + "execution_count": 6, |
| 77 | + "id": "based-blackberry", |
| 78 | + "metadata": {}, |
| 79 | + "outputs": [], |
| 80 | + "source": [ |
| 81 | + "research_invite = {\"@type\": \"did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0/invitation\", \"@id\": \"06fa0413-825f-4600-8bec-a582e5d75acc\", \"label\": \"Health Researcher\", \"serviceEndpoint\": \"http://172.17.0.1:8040\", \"recipientKeys\": [\"HrC95BgohtYLsTHjn6g4UspCx8tWzviGAg7PbvnRWHjZ\"]}" |
| 82 | + ] |
| 83 | + }, |
| 84 | + { |
| 85 | + "cell_type": "code", |
| 86 | + "execution_count": 7, |
| 87 | + "id": "dated-beverage", |
| 88 | + "metadata": {}, |
| 89 | + "outputs": [ |
| 90 | + { |
| 91 | + "name": "stdout", |
| 92 | + "output_type": "stream", |
| 93 | + "text": [ |
| 94 | + "Connection Handler Called\n", |
| 95 | + "Connection b16c712d-640e-4948-8ac6-ac767f3cddc2 in State invitation\n", |
| 96 | + "Connection Handler Called\n", |
| 97 | + "Connection b16c712d-640e-4948-8ac6-ac767f3cddc2 in State request\n", |
| 98 | + "Connection Handler Called\n", |
| 99 | + "Connection b16c712d-640e-4948-8ac6-ac767f3cddc2 in State response\n", |
| 100 | + "Connection Handler Called\n", |
| 101 | + "Connection b16c712d-640e-4948-8ac6-ac767f3cddc2 in State active\n", |
| 102 | + "Pending connection moved to active. Challenging with auth policy if set\n", |
| 103 | + "Trusted Research Connection Established - b16c712d-640e-4948-8ac6-ac767f3cddc2\n", |
| 104 | + "ML Message from b16c712d-640e-4948-8ac6-ac767f3cddc2\n", |
| 105 | + "Open file\n", |
| 106 | + "learning\n", |
| 107 | + "untrained_model.pt\n", |
| 108 | + "HOSPITAL MODEL LOADED\n", |
| 109 | + "HOSPITAL IS TRAINING\n", |
| 110 | + "loss at epoch 0 : tensor(0.2577)\n" |
| 111 | + ] |
| 112 | + }, |
| 113 | + { |
| 114 | + "name": "stderr", |
| 115 | + "output_type": "stream", |
| 116 | + "text": [ |
| 117 | + "/opt/conda/lib/python3.7/site-packages/torch/autograd/__init__.py:132: UserWarning: CUDA initialization: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx (Triggered internally at /pytorch/c10/cuda/CUDAFunctions.cpp:100.)\n", |
| 118 | + " allow_unreachable=True) # allow_unreachable flag\n" |
| 119 | + ] |
| 120 | + }, |
| 121 | + { |
| 122 | + "name": "stdout", |
| 123 | + "output_type": "stream", |
| 124 | + "text": [ |
| 125 | + "loss at epoch 5000 : tensor(0.1234)\n", |
| 126 | + "loss at epoch 10000 : tensor(0.1123)\n", |
| 127 | + "loss at epoch 15000 : tensor(0.1070)\n", |
| 128 | + "loss at epoch 20000 : tensor(0.1005)\n", |
| 129 | + "loss at epoch 25000 : tensor(0.0970)\n", |
| 130 | + "loss at epoch 30000 : tensor(0.0950)\n", |
| 131 | + "loss at epoch 35000 : tensor(0.0935)\n", |
| 132 | + "loss at epoch 40000 : tensor(0.0925)\n", |
| 133 | + "loss at epoch 45000 : tensor(0.0917)\n", |
| 134 | + "Learnt \n", |
| 135 | + "Trained file open\n", |
| 136 | + "connection ID b16c712d-640e-4948-8ac6-ac767f3cddc2\n" |
| 137 | + ] |
| 138 | + } |
| 139 | + ], |
| 140 | + "source": [ |
| 141 | + "hospital2.establish_research_connection(research_invite)" |
| 142 | + ] |
| 143 | + }, |
| 144 | + { |
| 145 | + "cell_type": "code", |
| 146 | + "execution_count": null, |
| 147 | + "id": "cardiovascular-typing", |
| 148 | + "metadata": {}, |
| 149 | + "outputs": [], |
| 150 | + "source": [] |
| 151 | + } |
| 152 | + ], |
| 153 | + "metadata": { |
| 154 | + "kernelspec": { |
| 155 | + "display_name": "Python 3", |
| 156 | + "language": "python", |
| 157 | + "name": "python3" |
| 158 | + }, |
| 159 | + "language_info": { |
| 160 | + "codemirror_mode": { |
| 161 | + "name": "ipython", |
| 162 | + "version": 3 |
| 163 | + }, |
| 164 | + "file_extension": ".py", |
| 165 | + "mimetype": "text/x-python", |
| 166 | + "name": "python", |
| 167 | + "nbconvert_exporter": "python", |
| 168 | + "pygments_lexer": "ipython3", |
| 169 | + "version": "3.8.5" |
| 170 | + } |
| 171 | + }, |
| 172 | + "nbformat": 4, |
| 173 | + "nbformat_minor": 5 |
| 174 | +} |
0 commit comments