Пример #1
0
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import numpy as np
import tensorflow as tf

import sys
sys.path.append('chatbot')
sys.path.append('utils')
from models.base_model import BaseModel

import misc_utils as utils
from models import model_helper

utils.check_tensorflow_version(version="1.3.0")


class HierarchicalModel(BaseModel):
    """
    Sequence-to-sequence hierarchical model.

    This class implements a multi-layer recurrent neural network as encoder,
    a multi-layer recurrent neural network as a context encoder
    and a multi-layer recurrent neural network decoder.
    """

    def _build_encoder(self, hparams):
        """Build an encoder"""
        encoder_num_layers = hparams.num_layers
        encoder_num_residual_layers = hparams.num_residual_layers

from __future__ import print_function

import os

import tensorflow as tf

import sys
sys.path.append('utils')
#from utils import misc_utils as utils
#from utils import vocab_utils
import misc_utils as utils
import vocab_utils

utils.check_tensorflow_version()


def add_arguments(parser):
    """Build the arguements parser"""
    # Register the boolean type. This allows us to use booleans as arguments
    parser.register('type', 'bool', lambda v: v.lower == "true")

    # Hyperparameters regarding the neural network
    parser.add_argument("--num_units", type=int, default=32, help="Network size.")
    parser.add_argument("--num_layers", type=int, default=2,
                        help="Network depth.")
    parser.add_argument("--encoder_type", type=str, default="uni", help="""\
        uni | bi. For bi, we build num_layers/2 bi-directional layers.""")
    parser.add_argument("--residual", type="bool", nargs="?", const=True,
                        default=False,