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
| """ | |
| Author: Awni Hannun | |
| This is an example CTC decoder written in Python. The code is | |
| intended to be a simple example and is not designed to be | |
| especially efficient. | |
| The algorithm is a prefix beam search for a model trained | |
| with the CTC loss function. |
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 | |
| from torch.autograd import Variable, Function | |
| class Linear(Function): | |
| # Note that both forward and backward are @staticmethods | |
| @staticmethod | |
| # bias is an optional argument | |
| def forward(ctx, input, weight, bias=None): | |
| ctx.save_for_backward(input, weight, bias) |
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
| # Author: Mathieu Blondel | |
| # License: BSD 3 clause | |
| import numpy as np | |
| def projection_simplex(V, z=1, axis=None): | |
| """ | |
| Projection of x onto the simplex, scaled by z: | |
| P(x; z) = argmin_{y >= 0, sum(y) = z} ||y - x||^2 |
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
| Windows Registry Editor Version 5.00 | |
| [HKEY_CLASSES_ROOT\.md] | |
| @="markdown" | |
| [HKEY_CLASSES_ROOT\.md\ShellNew] | |
| "NullFile"="" | |
| [HKEY_CLASSES_ROOT\markdown] | |
| @="Blank Markdown file" |
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
| # Instructions for installing GCC 4.9 on various platforms. | |
| # The commands show instructions for GCC 4.9, but any higher version will also work! | |
| # Ubuntu (https://askubuntu.com/questions/466651/how-do-i-use-the-latest-gcc-on-ubuntu/581497#581497) | |
| sudo apt-get install software-properties-common | |
| sudo add-apt-repository ppa:ubuntu-toolchain-r/test | |
| sudo apt-get update | |
| sudo apt-get install gcc-4.9 g++-4.9 | |
| sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9 |
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
| #!/usr/bin/env python | |
| # -*- coding:UTF-8 -*- | |
| import torch | |
| import torch.nn as nn | |
| import torch.nn.init as init | |
| def weight_init(m): | |
| ''' |
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
| model.zero_grad() # Reset gradients tensors | |
| for i, (inputs, labels) in enumerate(training_set): | |
| predictions = model(inputs) # Forward pass | |
| loss = loss_function(predictions, labels) # Compute loss function | |
| loss = loss / accumulation_steps # Normalize our loss (if averaged) | |
| loss.backward() # Backward pass | |
| if (i+1) % accumulation_steps == 0: # Wait for several backward steps | |
| optimizer.step() # Now we can do an optimizer step | |
| model.zero_grad() # Reset gradients tensors | |
| if (i+1) % evaluation_steps == 0: # Evaluate the model when we... |
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
| ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
| ## Created by: Hang Zhang, Rutgers University, Email: [email protected] | |
| ## Modified by Thomas Wolf, HuggingFace Inc., Email: [email protected] | |
| ## Copyright (c) 2017-2018 | |
| ## | |
| ## This source code is licensed under the MIT-style license found in the | |
| ## LICENSE file in the root directory of this source tree | |
| ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | |
| """Encoding Data Parallel""" |
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.nn | |
| import collections | |
| class Builder(object): | |
| def __init__(self, *namespaces): | |
| self._namespace = collections.ChainMap(*namespaces) | |
| def __call__(self, name, *args, **kwargs): | |
| try: | |
| return self._namespace[name](*args, **kwargs) |
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
| # Author: bbrighttaer | |
| # Date: 5/24/19 | |
| # Time: 12:27 AM | |
| # File: math.py | |
| from __future__ import division | |
| from __future__ import print_function | |
| from __future__ import unicode_literals |