Skip to content

mxnet to pytorch #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions tensor_regression_layer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"source": [
"# Tensor Regression Networks with ``TensorLy`` and ``PyTorch`` as a backend\n",
"\n",
"In this notebook, we will show how to combine TensorLy and MXNet in to implement the tensor regression layer, as defined in **Tensor Contraction & Regression Networks**, _Jean Kossaifi, Zachary C. Lipton, Aran Khanna, Tommaso Furlanello and Anima Anandkumar_, [ArXiV pre-publication](https://arxiv.org/abs/1707.08308).\n",
"In this notebook, we will show how to combine TensorLy and PyTorch in to implement the tensor regression layer, as defined in **Tensor Contraction & Regression Networks**, _Jean Kossaifi, Zachary C. Lipton, Aran Khanna, Tommaso Furlanello and Anima Anandkumar_, [ArXiV pre-publication](https://arxiv.org/abs/1707.08308).\n",
"\n",
"\n",
"Specifically, we use [TensorLy](http://tensorly.org/dev/index.html) for the tensor operations, with the [PyTorch](http://pytorch.org/) backend.\n",
Expand Down Expand Up @@ -124,7 +124,7 @@
" return F.log_softmax(x)\n",
"```\n",
"\n",
"In this notebook, we will demonstrate how to implement easily the TRL using TensorLy and MXNet."
"In this notebook, we will demonstrate how to implement easily the TRL using TensorLy and PyTorch."
]
},
{
Expand All @@ -142,16 +142,13 @@
"source": [
"import torch\n",
"import torch.nn as nn\n",
"from torch.autograd import Variable\n",
"import torch.optim as optim\n",
"from torchvision import datasets, transforms\n",
"import torch.nn.functional as F\n",
"\n",
"import numpy as np\n",
"\n",
"import tensorly as tl\n",
"from tensorly.tenalg import inner\n",
"from tensorly.random import check_random_state"
"from tensorly.tenalg import inner"
]
},
{
Expand Down Expand Up @@ -187,7 +184,7 @@
"batch_size = 16\n",
"device = 'cuda:0'\n",
"# to run on CPU, uncomment the following line:\n",
"device = 'cpu'"
"# device = 'cpu'"
]
},
{
Expand Down Expand Up @@ -274,7 +271,7 @@
" def penalty(self, order=2):\n",
" penalty = tl.norm(self.core, order)\n",
" for f in self.factors:\n",
" penatly = penalty + tl.norm(f, order)\n",
" penalty = penalty + tl.norm(f, order)\n",
" return penalty\n"
]
},
Expand Down Expand Up @@ -395,7 +392,7 @@
],
"source": [
"n_epoch = 5 # Number of epochs\n",
"regularizer = 0.001\n",
"regularizer = 0.0001\n",
"\n",
"model = model.to(device)\n",
"\n",
Expand Down
3 changes: 1 addition & 2 deletions tt-compression.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
"\n",
"import numpy as np\n",
"\n",
"import tensorly as tl\n",
"from tensorly.random import check_random_state"
"import tensorly as tl"
]
},
{
Expand Down