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 as tf | |
import sys | |
import time | |
import os | |
assert len(sys.argv) == 2, f"Usage: {sys.argv[0]} <directory>" | |
dirname = sys.argv[1] | |
print(dirname) | |
md_file = os.path.join(dirname, 'md.yml') | |
input_files = tf.io.gfile.glob(os.path.join(dirname, '*.tfrecord')) |
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 baseline.reader import register_reader, SeqLabelReader | |
from baseline.vectorizers import register_vectorizer, create_vectorizer, Vectorizer | |
from collections import Counter | |
from baseline.data import DataFeed | |
from baseline.embeddings import register_embeddings | |
from baseline.tf.embeddings import TensorFlowEmbeddings | |
from baseline.utils import read_json | |
import numpy as np | |
import tensorflow as tf |
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 | |
class Highway(nn.Module): | |
def __init__(self, input_size): | |
super(Highway, self).__init__() | |
self.proj = nn.Linear(input_size, input_size) | |
self.transform = nn.Linear(input_size, input_size) | |
self.transform.bias.data.fill_(-2.0) |
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
package org.sgdtk.struct; | |
import java.util.ArrayList; | |
import java.util.List; | |
/** | |
* Extracts a an array of character shingle features from a sequence | |
* | |
* @author dpressel | |
*/ |
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
# Copyright (c) 2015-present, Facebook, Inc. | |
# All rights reserved. | |
# | |
# This source code is licensed under the BSD+Patents license found in the | |
# LICENSE file in the root directory of this source tree. | |
# -*- makefile -*- | |
# tested on CentOS 7, Ubuntu 16 and Ubuntu 14, see below to adjust flags to distribution. |
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 baseline.tf.tfy import * | |
import json | |
import os | |
from google.protobuf import text_format | |
from tensorflow.python.platform import gfile | |
from baseline.model import Tagger | |
from tensorflow.contrib.layers import fully_connected, xavier_initializer | |
class RNNWordBoWCharTaggerModel(Tagger): |
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 baseline.tf.tfy import * | |
import json | |
import os | |
from google.protobuf import text_format | |
from tensorflow.python.platform import gfile | |
from baseline.model import Tagger | |
from tensorflow.contrib.layers import fully_connected, xavier_initializer | |
class RNNWordTaggerModel(Tagger): |
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 baseline.pytorch.torchy import classify_bt, append2seq | |
from baseline.model import Classifier | |
class NBowMaxModel(nn.Module, Classifier): | |
def save(self, outname): | |
print('saving %s' % outname) |
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 baseline.pytorch.torchy import classify_bt, append2seq | |
from baseline.model import Classifier | |
class NBowModel(nn.Module, Classifier): | |
def save(self, outname): | |
print('saving %s' % outname) |
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 baseline import classifier_repl | |
# You can use any of the implementations interchangeably! | |
from baseline.keras.classify import ConvModel | |
import argparse | |
""" | |
Example of loading a previously trained classifier (in Keras) and interacting | |
with it using a shell. Your shell inputs (for the time being) should be | |
in the form the model tokenizes its training data. | |
""" |
NewerOlder