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 argparse | |
import re | |
import shutil | |
from pathlib import Path | |
from tqdm import tqdm | |
DISCLAIMER = """⚠️ Note that this file is in Markdown but contain specific syntax for our doc-builder (similar to MDX) that may not be | |
rendered properly in your Markdown viewer.""" |
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 transformers import PreTrainedModel, AutoConfig, AutoModel | |
class ModelWithMultipleChoiceHead(PreTrainedModel): | |
def __init__(self, config): | |
super().__init__(config) | |
base_model = AutoModel.from_config(config) |
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
# -*- coding: utf-8 -*- | |
import numpy as np | |
import _pickle as cPickle | |
import gzip | |
import json | |
import sys | |
import time | |
class Quadratic(object): | |
@staticmethod |
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 bash | |
pushd ~/swift/ | |
rm -rf usr | |
popd | |
pushd ~/download/ | |
rm swift-tensorflow-DEVELOPMENT-cuda10.0-cudnn7-ubuntu18.04.tar.gz | |
wget https://storage.googleapis.com/s4tf-kokoro-artifact-testing/latest/swift-tensorflow-DEVELOPMENT-cuda10.0-cudnn7-ubuntu18.04.tar.gz | |
tar -xf swift-tensorflow-DEVELOPMENT-cuda10.0-cudnn7-ubuntu18.04.tar.gz | |
mv usr/ ~/swift/ | |
mv ~/swift/usr/lib/python3.6 ~/swift/usr/lib/python3.7 |
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 TensorFlow | |
var xTrain = Tensor<Float>(randomNormal: [1024, 784]) | |
var yTrain = Tensor<Int32>(repeating: 0, shape: [1024]) | |
public struct MyModel: Layer { | |
public var layer1: Dense<Float> | |
public var layer2: Dense<Float> | |
public init(nIn: Int, nHid: Int, nOut: Int){ |
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.
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.optim as optim | |
import torch.nn.functional as F | |
class WeightDropout(nn.Module): | |
"A module that warps another layer in which some weights will be replaced by 0 during training." | |
def __init__(self, module, dropout, layer_names=['weight_hh_l0']): | |
super().__init__() |
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 torch.optim.optimizer import Optimizer, required | |
class LARS(Optimizer): | |
def __init__(self, params, lr=required, momentum=0, dampening=0, | |
weight_decay=0, nesterov=False, eta=0.001): | |
if lr is not required and lr < 0.0: | |
raise ValueError("Invalid learning rate: {}".format(lr)) | |
if momentum < 0.0: | |
raise ValueError("Invalid momentum value: {}".format(momentum)) |
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 on Mon Jan 29 08:27:26 2018 | |
On a random grid of letters, find the word that's worth the most of points. | |
A word can be drawn going in any direction (even diagonals), changing direction | |
at any time is allowed, the only thing that isn't is to use the same letter | |
twice. | |
The score of a word is the sum of the scores of the letters (depending on their | |
frequency) multiplied by its length minus two. | |
Example of use (have the dictionary in the same directory as the python file): | |
generate_grid() |