(means, logvars, decoder_inputs,
                       targets, weights,
                       buckets, decoder, latent_dec, sample,
                       softmax_loss_function=None,
                       per_example_loss=False, name=None)
return outputs, losses, KL_objs, KL_costs
Create a sequence-to-sequence model with support for bucketing.
Create a sequence-to-sequence model with support for bucketing.
Create a sequence - to - sequence model with support for bucketing .
def variational_decoder_with_buckets(means, logvars, decoder_inputs,
                       targets, weights,
                       buckets, decoder, latent_dec, sample,
                       softmax_loss_function=None,
                       per_example_loss=False, name=None):
  """Create a sequence-to-sequence model with support for bucketing.
  """
  if len(targets) < buckets[-1][1]:
    raise ValueError("Length of targets (%d) must be at least that of last"
                     "bucket (%d)." % (len(targets), buckets[-1][1]))
  if len(weights) < buckets[-1][1]:
    raise ValueError("Length of weights (%d) must be at least that of last"
                     "bucket (%d)." % (len(weights), buckets[-1][1]))

  all_inputs = decoder_inputs + targets + weights
  losses = []
  outputs = []
  KL_objs = []
  KL_costs = []
  with ops.name_scope(name, "variational_decoder_with_buckets", all_inputs):
    for j, bucket in enumerate(buckets):
      with variable_scope.variable_scope(variable_scope.get_variable_scope(),
                                           reuse=True if j > 0 else None):

        latent_vector, kl_obj, kl_cost = sample(means[j], logvars[j])
        decoder_initial_state = latent_dec(latent_vector)

        bucket_outputs, _ = decoder(decoder_initial_state, decoder_inputs[:bucket[1]])
        outputs.append(bucket_outputs)
        total_size = math_ops.add_n(weights[:bucket[1]])
        total_size += 1e-12
        KL_objs.append(tf.reduce_mean(kl_obj / total_size))
        KL_costs.append(tf.reduce_mean(kl_cost / total_size))
        if per_example_loss:
          losses.append(sequence_loss_by_example(
              outputs[-1], targets[:bucket[1]], weights[:bucket[1]],
              softmax_loss_function=softmax_loss_function))
        else:
          losses.append(sequence_loss(
              outputs[-1], targets[:bucket[1]], weights[:bucket[1]],
              softmax_loss_function=softmax_loss_function))

  return outputs, losses, KL_objs, KL_costs
def variational_decoder_with_buckets ( means , logvars , decoder_inputs , targets , weights , buckets , decoder , latent_dec , sample , softmax_loss_function = None , per_example_loss = False , name = None ) : if len ( targets ) < buckets [ - 1 ] [ 1 ] : raise ValueError ( "Length of targets (%d) must be at least that of last" "bucket (%d)." % ( len ( targets ) , buckets [ - 1 ] [ 1 ] ) ) if len ( weights ) < buckets [ - 1 ] [ 1 ] : raise ValueError ( "Length of weights (%d) must be at least that of last" "bucket (%d)." % ( len ( weights ) , buckets [ - 1 ] [ 1 ] ) ) all_inputs = decoder_inputs + targets + weights losses = [ ] outputs = [ ] KL_objs = [ ] KL_costs = [ ] with ops . name_scope ( name , "variational_decoder_with_buckets" , all_inputs ) : for j , bucket in enumerate ( buckets ) : with variable_scope . variable_scope ( variable_scope . get_variable_scope ( ) , reuse = True if j > 0 else None ) : latent_vector , kl_obj , kl_cost = sample ( means [ j ] , logvars [ j ] ) decoder_initial_state = latent_dec ( latent_vector ) bucket_outputs , _ = decoder ( decoder_initial_state , decoder_inputs [ : bucket [ 1 ] ] ) outputs . append ( bucket_outputs ) total_size = math_ops . add_n ( weights [ : bucket [ 1 ] ] ) total_size += 1e-12 KL_objs . append ( tf . reduce_mean ( kl_obj / total_size ) ) KL_costs . append ( tf . reduce_mean ( kl_cost / total_size ) ) if per_example_loss : losses . append ( sequence_loss_by_example ( outputs [ - 1 ] , targets [ : bucket [ 1 ] ] , weights [ : bucket [ 1 ] ] , softmax_loss_function = softmax_loss_function ) ) else : losses . append ( sequence_loss ( outputs [ - 1 ] , targets [ : bucket [ 1 ] ] , weights [ : bucket [ 1 ] ] , softmax_loss_function = softmax_loss_function ) ) return outputs , losses , KL_objs , KL_costs