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 torch.nn as nn | |
| import torch.nn.functional as F | |
| class SpatialSoftArgmax(nn.Module): | |
| """Spatial softmax as defined in [1]. | |
| Concretely, the spatial softmax of each feature | |
| map is used to compute a weighted mean of the pixel |
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 torch.nn as nn | |
| from torch.autograd import Variable | |
| from torch.nn import functional as F | |
| """ | |
| Blog post: | |
| Taming LSTMs: Variable-sized mini-batches and why PyTorch is good for your health: | |
| https://medium.com/@_willfalcon/taming-lstms-variable-sized-mini-batches-and-why-pytorch-is-good-for-your-health-61d35642972e | |
| """ |
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
| #-------------------------- | |
| # USER-SPECIFIED DATA | |
| #-------------------------- | |
| # Tune these parameters | |
| num_classes = 2 | |
| image_shape = (160, 576) | |
| EPOCHS = 40 | |
| BATCH_SIZE = 16 |
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, torch.nn as nn | |
| from torch.autograd import Variable | |
| text = ['BOS', 'How', 'are', 'you', 'EOS'] | |
| seq_len = len(text) | |
| batch_size = 1 | |
| embedding_size = 1 | |
| hidden_size = 1 | |
| output_size = 1 |
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 numpy as np | |
| import sys | |
| import random | |
| import tensorflow as tf | |
| import itertools | |
| slim = tf.contrib.slim | |
| BATCH_SIZE = 32 | |
| TRAIN_ITER = 1000 | |
| EARLY_TRAIN_TERMINATE_CRITERIA = 1e-3; |
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 torch.nn as nn | |
| from torch.nn import functional as F | |
| from torch.autograd import Variable | |
| from torch import optim | |
| import numpy as np | |
| import math, random | |
| # Generating a noisy multi-sin wave |
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
| from keras.layers import Recurrent | |
| import keras.backend as K | |
| from keras import activations | |
| from keras import initializers | |
| from keras import regularizers | |
| from keras import constraints | |
| from keras.engine import Layer | |
| from keras.engine import InputSpec |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder