This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (setv train_loader (torch.utils.data.DataLoader | |
| (datasets.MNIST "./data" :train True :download True | |
| :transform (transforms.Compose (list | |
| ((transforms.ToTensor) | |
| (transforms.Normalize :std 0.1307 :mean 0.3081)) | |
| ))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def shape_list(x): | |
| """ | |
| deal with dynamic shape in tensorflow cleanly | |
| """ | |
| ps = x.get_shape().as_list() | |
| ts = tf.shape(x) | |
| return [ts[i] if ps[i] is None else ps[i] for i in range(len(ps))] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import torch | |
| import itertools | |
| def summed_permutations(matrix): | |
| columnwise_sum = torch.sum(matrix, dim=1) | |
| length = int(columnwise_sum.shape[0]) | |
| result = torch.cat([ | |
| torch.index_select(columnwise_sum, dim=0, index=torch.LongTensor(each)) |
OlderNewer