|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "metadata": {}, |
| 7 | + "outputs": [], |
| 8 | + "source": [ |
| 9 | + "import torch\n", |
| 10 | + "import torch.nn as nn\n" |
| 11 | + ] |
| 12 | + }, |
| 13 | + { |
| 14 | + "cell_type": "code", |
| 15 | + "execution_count": 8, |
| 16 | + "metadata": {}, |
| 17 | + "outputs": [], |
| 18 | + "source": [ |
| 19 | + "class DummyMod(nn.Module):\n", |
| 20 | + " def __init__(self,ip_size):\n", |
| 21 | + " self.ip = nn.Linear(i,64)\n", |
| 22 | + " self.h1 = nn.Linear(64,128)\n", |
| 23 | + " self.h2 = nn.Linear(128,32)\n", |
| 24 | + " self.op = nn.Linear(32,1)\n", |
| 25 | + " self.sigmo = nn.Sigmoid()\n", |
| 26 | + " \n", |
| 27 | + " def forward(x):\n", |
| 28 | + " x = self.ip(x)\n", |
| 29 | + " x = self.h1(x)\n", |
| 30 | + " x = self.sigmo(x)\n", |
| 31 | + " x = self.h2(x)\n", |
| 32 | + " x = self.op(x)\n", |
| 33 | + " return(x)\n", |
| 34 | + " \n", |
| 35 | + " " |
| 36 | + ] |
| 37 | + }, |
| 38 | + { |
| 39 | + "cell_type": "code", |
| 40 | + "execution_count": 9, |
| 41 | + "metadata": {}, |
| 42 | + "outputs": [ |
| 43 | + { |
| 44 | + "name": "stdout", |
| 45 | + "output_type": "stream", |
| 46 | + "text": [ |
| 47 | + "DummyMod(\n", |
| 48 | + " (ip): Linear(in_features=128, out_features=64, bias=True)\n", |
| 49 | + " (h1): Linear(in_features=64, out_features=128, bias=True)\n", |
| 50 | + " (h2): Linear(in_features=128, out_features=32, bias=True)\n", |
| 51 | + " (op): Linear(in_features=32, out_features=1, bias=True)\n", |
| 52 | + " (sigmo): Sigmoid()\n", |
| 53 | + ")\n" |
| 54 | + ] |
| 55 | + } |
| 56 | + ], |
| 57 | + "source": [ |
| 58 | + "model = DummyMod()\n", |
| 59 | + "print(model)" |
| 60 | + ] |
| 61 | + }, |
| 62 | + { |
| 63 | + "cell_type": "code", |
| 64 | + "execution_count": null, |
| 65 | + "metadata": {}, |
| 66 | + "outputs": [], |
| 67 | + "source": [] |
| 68 | + } |
| 69 | + ], |
| 70 | + "metadata": { |
| 71 | + "kernelspec": { |
| 72 | + "display_name": "Python 3", |
| 73 | + "language": "python", |
| 74 | + "name": "python3" |
| 75 | + }, |
| 76 | + "language_info": { |
| 77 | + "codemirror_mode": { |
| 78 | + "name": "ipython", |
| 79 | + "version": 3 |
| 80 | + }, |
| 81 | + "file_extension": ".py", |
| 82 | + "mimetype": "text/x-python", |
| 83 | + "name": "python", |
| 84 | + "nbconvert_exporter": "python", |
| 85 | + "pygments_lexer": "ipython3", |
| 86 | + "version": "3.6.8" |
| 87 | + } |
| 88 | + }, |
| 89 | + "nbformat": 4, |
| 90 | + "nbformat_minor": 2 |
| 91 | +} |
0 commit comments