Exemplo n.º 1
0
#!/usr/bin/env python

import logging

import qnd
import qndex
import font2char2word2sent2doc as f2c2w2s2d

model = f2c2w2s2d.def_char2word2sent2doc()
read_file = qndex.nlp.sentiment_analysis.def_read_file()
train_and_evaluate = qnd.def_train_and_evaluate()


def main():
    logging.getLogger().setLevel(logging.INFO)
    train_and_evaluate(model, read_file)


if __name__ == '__main__':
    main()
Exemplo n.º 2
0
import logging
import os

import qnd

import mnist

train_and_evaluate = qnd.def_train_and_evaluate(
    distributed=("distributed" in os.environ))

model = mnist.def_model()


def main():
    logging.getLogger().setLevel(logging.INFO)
    train_and_evaluate(model, mnist.read_file)


if __name__ == "__main__":
    main()
Exemplo n.º 3
0
        "number": number
    }) if env("use_dict_inputs") else (image, number))


mnist_model = mnist.def_model()


def model(image, number=None, mode=tf.contrib.learn.ModeKeys.TRAIN):
    results = mnist_model(image, number, mode)

    return (tf.contrib.learn.ModelFnOps(mode, *results)
            if env("use_model_fn_ops") else results)


train_and_evaluate = qnd.def_train_and_evaluate(
    batch_inputs=(not env("self_batch")),
    prepare_filename_queues=(not env("self_filename_queue")))


def main():
    logging.getLogger().setLevel(logging.INFO)

    def def_input_fn(batch_fn, filename_queue_fn):
        def batch(*tensors):
            return batch_fn(*tensors) if env("self_batch") else tensors

        if env("self_filename_queue"):

            def input_fn():
                return batch(*read_file(filename_queue_fn()))
        else:
#!/usr/bin/env python

import logging

import qnd
import qndex
import font2char2word2sent2doc as f2c2w2s2d


model = f2c2w2s2d.def_font2char2word2sent2doc()
read_file = qndex.nlp.sentiment_analysis.def_read_file()
train_and_evaluate = qnd.def_train_and_evaluate()


def main():
    logging.getLogger().setLevel(logging.INFO)
    train_and_evaluate(model, read_file)


if __name__ == '__main__':
    main()
Exemplo n.º 5
0
        length.set_shape([])

        reshape = lambda sequence: tf.reshape(sequence, tf.pack([length]))
        return reshape(sentence), reshape(labels)

    return convert_text


def def_read_file():
    convert_text = def_convert_text()

    def read_file(filename_queue):
        key, value = tf.WholeFileReader().read(filename_queue)
        sentence, labels = convert_text(value)
        return {'key': key, 'sentence': sentence}, {'labels': labels}

    return read_file


char_lm = font2char_lm.def_char_lm()
read_file = def_read_file()
train_and_evaluate = qnd.def_train_and_evaluate(batch_inputs=False)


def main():
    train_and_evaluate(char_lm, read_file)


if __name__ == '__main__':
    main()