Beispiel #1
0
    from tensorlayer import decorators
    from tensorlayer import files
    from tensorlayer import initializers
    from tensorlayer import iterate
    from tensorlayer import layers
    from tensorlayer import lazy_imports
    from tensorlayer import logging
    from tensorlayer import models
    from tensorlayer import optimizers
    from tensorlayer import rein
    from tensorlayer import utils

    from tensorlayer.lazy_imports import LazyImport

    # Lazy Imports
    db = LazyImport("tensorlayer.db")
    distributed = LazyImport("tensorlayer.distributed")
    nlp = LazyImport("tensorlayer.nlp")
    prepro = LazyImport("tensorlayer.prepro")
    utils = LazyImport("tensorlayer.utils")
    visualize = LazyImport("tensorlayer.visualize")

    # alias
    act = activation
    vis = visualize

    alphas = array_ops.alphas
    alphas_like = array_ops.alphas_like

    # global vars
    global_flag = {}
Beispiel #2
0
#! /usr/bin/python
# -*- coding: utf-8 -*-

import inspect
import pickle
import time
import uuid

from datetime import datetime

from tensorlayer.lazy_imports import LazyImport

gridfs = LazyImport("gridfs")
pymongo = LazyImport("pymongo")


def AutoFill(func):
    def func_wrapper(self, *args, **kwargs):
        d = inspect.getcallargs(func, self, *args, **kwargs)
        d['args'].update({"studyID": self.studyID})
        return func(**d)

    return func_wrapper


class TensorDB(object):
    """TensorDB is a MongoDB based manager that help you to manage data, network topology, parameters and logging.

    Parameters
    -------------
    ip : str
Beispiel #3
0
# -*- coding: utf-8 -*-
"""
TensorLayer provides rich layer implementations trailed for
various benchmarks and domain-specific problems. In addition, we also
support transparent access to native TensorFlow parameters.
For example, we provide not only layers for local response normalization, but also
layers that allow user to apply ``tf.nn.lrn`` on ``network.outputs``.
More functions can be found in `TensorFlow API <https://www.tensorflow.org/versions/master/api_docs/index.html>`__.
"""

from tensorlayer.lazy_imports import LazyImport

from .tl_logging import *

# Lazy Imports
contrib = LazyImport("tensorlayer.logging.contrib")

__all__ = [
    # tl_logging
    'DEBUG',
    'debug',
    'ERROR',
    'error',
    'FATAL',
    'fatal',
    'INFO',
    'info',
    'WARN',
    'warn',
    'warning',
    'set_verbosity',
Beispiel #4
0
#! /usr/bin/python
# -*- coding: utf-8 -*-

from tensorlayer.layers.core import Layer

from tensorlayer import tl_logging as logging

from tensorlayer.decorators import deprecated_alias

from tensorlayer.lazy_imports import LazyImport

try:
    roi_pooling = LazyImport(
        "tensorlayer.third_party.roi_pooling.roi_pooling.roi_pooling_ops")
except Exception as e:
    logging.error(e)
    logging.error(
        "HINT: 1. https://github.com/deepsense-ai/roi-pooling  2. tensorlayer/third_party/roi_pooling"
    )

__all__ = [
    'ROIPoolingLayer',
]


class ROIPoolingLayer(Layer):
    """
    The region of interest pooling layer.

    Parameters
    -----------
Beispiel #5
0
import subprocess
import tempfile
import warnings

from six.moves import urllib
from six.moves import xrange

import numpy as np

import tensorflow as tf
from tensorflow.python.platform import gfile

import tensorlayer as tl
from tensorlayer.lazy_imports import LazyImport

nltk = LazyImport("nltk")

__all__ = [
    'generate_skip_gram_batch',
    'sample',
    'sample_top',
    'SimpleVocabulary',
    'Vocabulary',
    'process_sentence',
    'create_vocab',
    'simple_read_words',
    'read_words',
    'read_analogies_file',
    'build_vocab',
    'build_reverse_dictionary',
    'build_words_dataset',
Beispiel #6
0
#! /usr/bin/python
# -*- coding: utf-8 -*-

import os

import imageio
import numpy as np

import tensorlayer as tl
from tensorlayer.lazy_imports import LazyImport

cv2 = LazyImport("cv2")

# Uncomment the following line if you got: _tkinter.TclError: no display name and no $DISPLAY environment variable
# import matplotlib
# matplotlib.use('Agg')

__all__ = [
    'read_image',
    'read_images',
    'save_image',
    'save_images',
    'draw_boxes_and_labels_to_image',
    'draw_mpii_people_to_image',
    'frame',
    'CNN2d',
    'images2d',
    'tsne_embedding',
    'draw_weights',
    'W',
]
Beispiel #7
0
# -*- coding: utf-8 -*-

import json
import os
import time
import math

import tensorflow as tf
from tensorflow.python.training import session_run_hook

from tensorlayer import logging
from tensorlayer.decorators import deprecated
from tensorlayer.lazy_imports import LazyImport

hvd = LazyImport('horovod.tensorflow')

__all__ = [
    'TaskSpecDef', 'TaskSpec', 'DistributedSession', 'StopAtTimeHook',
    'LoadCheckpoint', 'Trainer'
]


class Trainer(object):
    """Trainer for neural networks in a distributed environment.

    TensorLayer Trainer is a high-level training interface built on top of TensorFlow MonitoredSession and
    `Horovod <https://github.com/uber/horovod>`__. It transparently scales the training of a TensorLayer model
    from a single GPU to multiple GPUs that be placed on different machines in a single cluster.

    To run the trainer, you will need to install Horovod on your machine. Check the installation script at
    `tensorlayer/scripts/download_and_install_openmpi3_ubuntu.sh`