Python base 模块,Model() 实例源码

我们从Python开源项目中,提取了以下4个代码示例,用于说明如何使用base.Model()

项目:variational-text-tensorflow    作者:carpedm20    | 项目源码 | 文件源码
def __init__(self, sess, reader, dataset="ptb",
               batch_size=20, num_steps=3, embed_dim=500,
               h_dim=50, learning_rate=0.01, epoch=50,
               checkpoint_dir="checkpoint"):
    """Initialize Neural Varational Document Model.

    params:
      sess: TensorFlow Session object.
      reader: TextReader object for training and test.
      dataset: The name of dataset to use.
      h_dim: The dimension of document representations (h). [50, 200]
    """
    self.sess = sess
    self.reader = reader

    self.h_dim = h_dim
    self.embed_dim = embed_dim

    self.epoch = epoch
    self.batch_size = batch_size
    self.learning_rate = learning_rate
    self.checkpoint_dir = checkpoint_dir

    self.dataset="ptb"
    self._attrs=["batch_size", "num_steps", "embed_dim", "h_dim", "learning_rate"]

    raise Exception(" [!] Working in progress")
    self.build_model()
项目:variational-text-tensorflow    作者:carpedm20    | 项目源码 | 文件源码
def __init__(self, sess, reader, dataset="ptb",
               decay_rate=0.96, decay_step=10000, embed_dim=500,
               h_dim=50, learning_rate=0.001, max_iter=450000,
               checkpoint_dir="checkpoint"):
    """Initialize Neural Varational Document Model.

    params:
      sess: TensorFlow Session object.
      reader: TextReader object for training and test.
      dataset: The name of dataset to use.
      h_dim: The dimension of document representations (h). [50, 200]
    """
    self.sess = sess
    self.reader = reader

    self.h_dim = h_dim
    self.embed_dim = embed_dim

    self.max_iter = max_iter
    self.decay_rate = decay_rate
    self.decay_step = decay_step
    self.checkpoint_dir = checkpoint_dir
    self.step = tf.Variable(0, trainable=False)  
    self.lr = tf.train.exponential_decay(
        learning_rate, self.step, 10000, decay_rate, staircase=True, name="lr")

    _ = tf.scalar_summary("learning rate", self.lr)

    self.dataset = dataset
    self._attrs = ["h_dim", "embed_dim", "max_iter", "dataset",
                   "learning_rate", "decay_rate", "decay_step"]

    self.build_model()
项目:variational_inference    作者:carpeanon    | 项目源码 | 文件源码
def __init__(self, sess, reader, dataset="ptb",
               batch_size=20, num_steps=3, embed_dim=500,
               h_dim=50, learning_rate=0.01, epoch=50,
               checkpoint_dir="checkpoint"):
    """Initialize Neural Varational Document Model.

    params:
      sess: TensorFlow Session object.
      reader: TextReader object for training and test.
      dataset: The name of dataset to use.
      h_dim: The dimension of document representations (h). [50, 200]
    """
    self.sess = sess
    self.reader = reader

    self.h_dim = h_dim
    self.embed_dim = embed_dim

    self.epoch = epoch
    self.batch_size = batch_size
    self.learning_rate = learning_rate
    self.checkpoint_dir = checkpoint_dir

    self.dataset="ptb"
    self._attrs=["batch_size", "num_steps", "embed_dim", "h_dim", "learning_rate"]

    raise Exception(" [!] Working in progress")
    self.build_model()
项目:variational_inference    作者:carpeanon    | 项目源码 | 文件源码
def __init__(self, sess, reader, dataset="ptb",
               decay_rate=0.96, decay_step=10000, embed_dim=500,
               h_dim=50, learning_rate=0.001, max_iter=450000,
               checkpoint_dir="checkpoint"):
    """Initialize Neural Varational Document Model.

    params:
      sess: TensorFlow Session object.
      reader: TextReader object for training and test.
      dataset: The name of dataset to use.
      h_dim: The dimension of document representations (h). [50, 200]
    """
    self.sess = sess
    self.reader = reader

    self.h_dim = h_dim
    self.embed_dim = embed_dim

    self.max_iter = max_iter
    self.decay_rate = decay_rate
    self.decay_step = decay_step
    self.checkpoint_dir = checkpoint_dir
    self.step = tf.Variable(0, trainable=False)  
    self.lr = tf.train.exponential_decay(
        learning_rate, self.step, 10000, decay_rate, staircase=True, name="lr")

    _ = tf.scalar_summary("learning rate", self.lr)

    self.dataset = dataset
    self._attrs = ["h_dim", "embed_dim", "max_iter", "dataset",
                   "learning_rate", "decay_rate", "decay_step"]

    self.build_model()