<commit_before>#!/usr/bin/env python

import numpy as np
import tensorflow as tf
from tensorflow.models.rnn import rnn
from rnn_cells import TPNLSTMCell, ResLSTMCell

class TPNModel(object):
  """The TPN model."""

  def __init__(self, is_training, config):
    self.batch_size = batch_size = config.batch_size
    self.num_steps = num_steps = config.num_steps
    self.input_size = input_size = config.input_size
    self.num_classes = num_classes = config.num_classes
    self.vid_per_batch = config.vid_per_batch
    size = config.hidden_size
    self.cls_weight = config.cls_weight
    self.bbox_weight = config.bbox_weight
    self.ending_weight = config.ending_weight
    self.iter_epoch = config.iter_epoch
    self.momentum = config.momentum

    # placeholders for inputs and outputs
    self._input_data = inputs = tf.placeholder(tf.float32, [batch_size, num_steps, input_size])
    self._cls_targets = tf.placeholder(tf.int32, [batch_size, num_steps])
    self._bbox_targets = tf.placeholder(tf.float32, [batch_size, num_steps, num_classes * 4])
    self._bbox_weights = tf.placeholder(tf.float32, [batch_size, num_steps, num_classes * 4])
    self._end_targets = tf.placeholder(tf.float32, [batch_size, num_steps])

    if is_training and config.keep_prob < 1:
      inputs = tf.nn.dropout(inputs, config.keep_prob)

    # original inputs: batch_size * input_size * num_steps
    # after process: num_steps * [batch_size, input_size]
    inputs = [tf.squeeze(input_, [1])
              for input_ in tf.split(1, num_steps, inputs)]


    lstm_cell = ResLSTMCell(size)
    if is_training and config.keep_prob < 1:<commit_msg>Add option to choose different LSTM units in TPNModel.<commit_after>#!/usr/bin/env python

import numpy as np
import tensorflow as tf
from tensorflow.models.rnn import rnn
from rnn_cells import TPNLSTMCell, ResLSTMCell
import glog as log
import cPickle

class TPNModel(object):
  """The TPN model."""

  def __init__(self, is_training, config):
    self.batch_size = batch_size = config.batch_size
    self.num_steps = num_steps = config.num_steps
    self.input_size = input_size = config.input_size
    self.num_classes = num_classes = config.num_classes
    self.vid_per_batch = config.vid_per_batch
    size = config.hidden_size
    self.cls_weight = config.cls_weight
    self.bbox_weight = config.bbox_weight
    self.ending_weight = config.ending_weight
    self.iter_epoch = config.iter_epoch
    self.momentum = config.momentum

    # placeholders for inputs and outputs
    self._input_data = inputs = tf.placeholder(tf.float32, [batch_size, num_steps, input_size])
    self._cls_targets = tf.placeholder(tf.int32, [batch_size, num_steps])
    self._bbox_targets = tf.placeholder(tf.float32, [batch_size, num_steps, num_classes * 4])
    self._bbox_weights = tf.placeholder(tf.float32, [batch_size, num_steps, num_classes * 4])
    self._end_targets = tf.placeholder(tf.float32, [batch_size, num_steps])

    if is_training and config.keep_prob < 1:
      inputs = tf.nn.dropout(inputs, config.keep_prob)

    # original inputs: batch_size * input_size * num_steps
    # after process: num_steps * [batch_size, input_size]
    inputs = [tf.squeeze(input_, [1])
              for input_ in tf.split(1, num_steps, inputs)]


    self.type = config.type
    if self.type == 'residual':
      lstm_cell = ResLSTMCell(size)
    elif self.type == 'basic':
      lstm_cell = tf.models.rnn.rnn_cell.BasicLSTMCell(size)
    else:
      raise ValueError('Unknown LSTM cell type: {}.'.format(self.type))
    if is_training and config.keep_prob < 1:
{'fraction_non_alphanumeric': 0.09879988836170807, 'fraction_numerical': 0.008931063354730673, 'mean_word_length': 3.923076923076923, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4179244', 'n_tokens_mistral': 1226, 'n_tokens_neox': 1188, 'n_words': 268}