{ "info": { "author": "Robin Br\u00fcgger", "author_email": "brueggerrobin+revtorch@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Science/Research", "License :: OSI Approved :: BSD License", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Topic :: Scientific/Engineering :: Artificial Intelligence" ], "description": "# RevTorch\nFramework for creating (partially) reversible neural networks with PyTorch\n\nRevTorch is introduced and explained in our paper [A Partially Reversible U-Net for Memory-Efficient Volumetric Image Segmentation](https://arxiv.org/abs/1906.06148),\nwhich was accepted for presentation at [MICCAI 2019](https://www.miccai2019.org/). \n\nIf you find this code helpful in your research please cite the following paper:\n```\n@article{PartiallyRevUnet2019Bruegger,\n author={Br{\\\"u}gger, Robin and Baumgartner, Christian F.\n and Konukoglu, Ender},\n title={A Partially Reversible U-Net for Memory-Efficient Volumetric Image Segmentation},\n journal={arXiv:1906.06148},\n year={2019},\n```\n\n## Installation\nUse pip to install RevTorch:\n```sh\n$ pip install revtorch\n```\nRevTorch requires PyTorch. However, PyTorch is not included in the dependencies since the required PyTorch version is dependent on your system. Please install PyTorch following the instructions on the [PyTorch website](https://pytorch.org/).\n\n## Usage\nThis example shows how to use the RevTorch framework.\n```python\nimport torch\nimport torchvision\nimport torchvision.transforms as transforms\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport torch.optim as optim\nimport revtorch as rv\n\ndef train():\n trainset = torchvision.datasets.CIFAR10(root=\"./data\", train=True, download=True, transform=transforms.ToTensor())\n trainloader = torch.utils.data.DataLoader(trainset, batch_size=4, shuffle=True)\n\n net = PartiallyReversibleNet()\n criterion = nn.CrossEntropyLoss()\n optimizer = optim.Adam(net.parameters())\n\n for epoch in range(2):\n\n running_loss = 0.0\n for i, data in enumerate(trainloader, 0):\n inputs, labels = data\n optimizer.zero_grad()\n outputs = net(inputs)\n loss = criterion(outputs, labels)\n loss.backward()\n optimizer.step()\n\n #logging stuff\n running_loss += loss.item()\n LOG_INTERVAL = 200\n if i % LOG_INTERVAL == (LOG_INTERVAL-1): # print every 2000 mini-batches\n print('[%d, %5d] loss: %.3f' % (epoch + 1, i + 1, running_loss / LOG_INTERVAL))\n running_loss = 0.0\n\nclass PartiallyReversibleNet(nn.Module):\n def __init__(self):\n super(PartiallyReversibleNet, self).__init__()\n\n #initial non-reversible convolution to get to 32 channels\n self.conv1 = nn.Conv2d(3, 32, 3)\n\n #construct reversible sequencce with 4 reversible blocks\n blocks = []\n for i in range(4):\n\n #f and g must both be a nn.Module whos output has the same shape as its input\n f_func = nn.Sequential(nn.ReLU(), nn.Conv2d(16, 16, 3, padding=1))\n g_func = nn.Sequential(nn.ReLU(), nn.Conv2d(16, 16, 3, padding=1))\n\n #we construct a reversible block with our F and G functions\n blocks.append(rv.ReversibleBlock(f_func, g_func))\n\n #pack all reversible blocks into a reversible sequence\n self.sequence = rv.ReversibleSequence(nn.ModuleList(blocks))\n\n #non-reversible convolution to get to 10 channels (one for each label)\n self.conv2 = nn.Conv2d(32, 10, 3)\n\n def forward(self, x):\n x = self.conv1(x)\n\n #the reversible sequence can be used like any other nn.Module. Memory-saving backpropagation is used automatically\n x = self.sequence(x)\n\n x = self.conv2(F.relu(x))\n x = F.avg_pool2d(x, (x.shape[2], x.shape[3]))\n x = x.view(x.shape[0], x.shape[1])\n return x\n\nif __name__ == \"__main__\":\n train()\n```\n\n## Python version\nTested with Python 3.6 and PyTorch 1.1.0. Should work with any version of Python 3.", "description_content_type": "text/markdown", "docs_url": null, "download_url": "https://github.com/RobinBruegger/RevTorch/archive/v0.2.0.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/RobinBruegger/RevTorch", "keywords": "reversbile neural network", "license": "bsd-3-clause", "maintainer": "", "maintainer_email": "", "name": "revtorch", "package_url": "https://pypi.org/project/revtorch/", "platform": "", "project_url": "https://pypi.org/project/revtorch/", "project_urls": { "Download": "https://github.com/RobinBruegger/RevTorch/archive/v0.2.0.tar.gz", "Homepage": "https://github.com/RobinBruegger/RevTorch" }, "release_url": "https://pypi.org/project/revtorch/0.2.0/", "requires_dist": null, "requires_python": "", "summary": "Framework for creating (partially) reversible neural networks with PyTorch", "version": "0.2.0" }, "last_serial": 5832381, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "883389f9f732fb16808561a6404452d0", "sha256": "af9307d1250286c7c16a23c19f711af33b3dccc2cd98f1bc7b2e91cacfcd2695" }, "downloads": -1, "filename": "revtorch-0.1.0.tar.gz", "has_sig": false, "md5_digest": "883389f9f732fb16808561a6404452d0", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2819, "upload_time": "2019-06-13T11:41:28", "url": "https://files.pythonhosted.org/packages/df/e3/28327129901ac65131ad8a948060a06642f0645ac52a1b25a1f7a0540c04/revtorch-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "f192076fb02e8261cb720ce340ce987a", "sha256": "a8bf17a05b8a4c7a3d0e559305ce3080d6fbdd6ab463764f03ad970541fa2ad6" }, "downloads": -1, "filename": "revtorch-0.1.1.tar.gz", "has_sig": false, "md5_digest": "f192076fb02e8261cb720ce340ce987a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4946, "upload_time": "2019-06-18T15:56:07", "url": "https://files.pythonhosted.org/packages/e0/f0/10869ad425c8de0bee0ebd254d1ec75af69e9e1c7c97a2b4e828deede789/revtorch-0.1.1.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "0681cc6f6891e1572ccaaa86b44b477d", "sha256": "107b72f9dc3a8a581bb57e5909fea414bda2f738e916ffea5a0338c1cf3c9862" }, "downloads": -1, "filename": "revtorch-0.2.0.tar.gz", "has_sig": false, "md5_digest": "0681cc6f6891e1572ccaaa86b44b477d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4934, "upload_time": "2019-09-15T15:50:56", "url": "https://files.pythonhosted.org/packages/ee/af/6b44c2def528b4d80e1f5719ef5954422e2efe4efeccc569d7075292054d/revtorch-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "0681cc6f6891e1572ccaaa86b44b477d", "sha256": "107b72f9dc3a8a581bb57e5909fea414bda2f738e916ffea5a0338c1cf3c9862" }, "downloads": -1, "filename": "revtorch-0.2.0.tar.gz", "has_sig": false, "md5_digest": "0681cc6f6891e1572ccaaa86b44b477d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4934, "upload_time": "2019-09-15T15:50:56", "url": "https://files.pythonhosted.org/packages/ee/af/6b44c2def528b4d80e1f5719ef5954422e2efe4efeccc569d7075292054d/revtorch-0.2.0.tar.gz" } ] }