seed
stringlengths
25
2.89k
seed_api
stringlengths
14
102
index
int64
0
14.8k
import tensorflow as tf from src.nn_utils.general import exp_mask_for_high_rank, mask_for_high_rank from src.nn_utils.integration_func import directional_attention_with_dense from src.nn_utils.nn import bn_dense_layer, linear def bi_directional_simple_block_attention( rep_tensor, rep_mask, block_len=5, scope...
tensorflow.variable_scope
14,700
import tensorflow as tf num_or_size_splits=num_of_joints, axis=-1) losses = [] # 计算每一个关键点的损失值,并累加求平均 for i in range(num_of_joints): heatmap_pred = tf.squeeze(heatmap_pred_list[i]) heatmap_true = tf.squeeze(heatmap_true_list...
tensorflow.squeeze
14,701
import tensorflow as tf [self.vocab.word_size() - 2, self.vocab.word_embed_dim], dtype=tf.float32, initializer=tf.constant_initializer( ...
tensorflow.concat
14,702
import tensorflow as tf log_probs = tf.nn.log_softmax(logits, axis=-1) labels = tf.reshape(labels, [-1])
tensorflow.reshape
14,703
import tensorflow as tf step_callback: (optional) A function that will be called before each optimization step, step_callback(iteration, feed_dict) ''' if self.sess is not None: self.sess.close() self.sess = tf.Session(graph=self.graph) with self...
tensorflow.Session
14,704
import tensorflow as tf w1_a = tf.get_variable('w1_a', [self.a_dim, n_l1], initializer=init_w, trainable=trainable) b1 = tf.get_variable('b1', [1, n_l1], initializer=init_b, trainable=trainable)
tensorflow.get_variable
14,705
import tensorflow as tf else: return tf.reshape(tf.stack(values=h, axis=1), [-1]) def lstm(xs, ms, s, scope, nh, init_scale=1.0): nbatch, nin = [v.value for v in xs[0].get_shape()] with tf.variable_scope(scope): wx = tf.get_variable("wx", [nin, nh*4], initializer=ortho_init(init_scale)) ...
tensorflow.matmul
14,706
import tensorflow as tf left_in.append(tf.random_normal((1, size * 2))) right_in.append(tf.random_normal((1, size * 2))) tracking.append(tf.random_normal((1, tracker_size * 2))) out = reducer(left_in, right_in, tracking=tracking) self.assertEqual(batch_size, len(out)) self.as...
tensorflow.device
14,707
import tensorflow as tf gan_train_ops = tf.contrib.gan.gan_train_ops(gan_model, gan_loss, gen_optimizer, dis_optimizer) while_loop = tf.contrib.tpu.while_loop if params['use_tpu'] else tf.while_loop # train the discriminator 100 steps inputs = [tf.constant(0), tf.constant(0.0)] ...
tensorflow.constant
14,708
import tensorflow as tf # Create connected layers: fc1, fc2 with tf.contrib.framework.arg_scope([tf.contrib.layers.fully_connected], normalizer_fn=tf.contrib.layers.batch_norm, normalizer_params={...
tensorflow.name_scope
14,709
import tensorflow as tf kernel = _variable_with_weight_decay('weights', shape=kernel_shape, use_xavier=use_xavier, stddev=stddev, w...
tensorflow.constant_initializer
14,710
import tensorflow as tf if alpha > 0: return tf.maximum(alpha * x, x, name=name) else: return tf.nn.relu(x, name=name)
tensorflow.nn.relu
14,711
import tensorflow as tf val_losses = np.array(val_losses) return (training_losses,val_losses, int(parameter_num)) """ Test RNN graph 0 step """ def test_rnn(test_data_x,test_data_y, g, checkpoint, input_prob, output_prob, state_prob, num_test): with tf.Session() as sess: ...
tensorflow.Session
14,712
import tensorflow as tf self.is_training = tf.placeholder(tf.bool) initializer = tf.contrib.layers.variance_scaling_initializer() # Embedding Lookup 16 with tf.device('/cpu:0'), tf.name_scope("embedding"): if use_he_uniform: self.embedding_W = tf.ge...
tensorflow.get_variable
14,713
import tensorflow as tf numpy.random.seed(42) tf.set_random_seed(1234) sess = tf.Session(graph=tf.get_default_graph())
tensorflow.set_random_seed
14,714
import tensorflow as tf pred, K, reprojected, crit_fake = model(x2d) crit_real = model.crit(x3d) crit_dis = tf.reduce_mean(tf.square(crit_real - tf.ones_like(crit_real))) + tf.reduce_mean(tf.square(crit_fake - tf.zeros_like(crit_fake))) crit_gen = tf.reduce_mean(tf.square(crit_fake - tf.ones_like(crit_fake)))...
tensorflow.zeros_like
14,715
import tensorflow as tf f2 = tf.reduce_sum(half(masked, 1), 2) / tf.reduce_sum(half(mask, 1)) return tf.concat([x, f1, f2], 1) def batch_norm(x, train, name, decay=0.99, epsilon=1e-5): shape = x.get_shape().as_list() with tf.variable_scope(name): beta = tf.get_variable('beta', [shape[-...
tensorflow.constant_initializer
14,716
import tensorflow as tf raise NotImplementedError() def get_labels(self): """Gets the list of labels for this data set.""" raise NotImplementedError() @classmethod def _read_tsv(cls, input_file, quotechar=None): """Reads a tab separated value file.""" with tf.gfile...
tensorflow.gfile.Open
14,717
import tensorflow as tf log_r = tf.cond( tf.less(t + 1, self.max_seq_len), lambda: self.tilt(rnn_out, latent_encoded, self.targets_ta.read(t+1)), lambda: 0.) # On the last step, log_r = 0. log_r *= tf.to_float(t < self.seq_lengths - 1) weights += log_r - prev...
tensorflow.to_float
14,718
import tensorflow as tf Returns: A boolean tensor of shape [M, N], True for entries which are sampled. """ def _minibatch_subsample_fn(inputs): indicators, targets = inputs return sample_balanced_positive_negative(tf.cast(indicators, tf.bool), ...
tensorflow.cast
14,719
import tensorflow as tf mask = tf.equal(mask, tf.ones_like(mask)) hidden_size = facts.get_shape().as_list()[-1] # D value - hidden size of the RNN layer input_size = query.get_shape().as_list()[-1] # Trainable parameters w1 = tf.Variable(tf.random_normal([hidden_size, attention_size], stddev=0.1)...
tensorflow.tensordot
14,720
import tensorflow as tf # model related configuration tf.app.flags.DEFINE_integer( 'train_image_size', 352, 'The size of the input image for the model to use.') tf.app.flags.DEFINE_integer( 'resnet_size', 50, 'The size of the ResNet model to use.') tf.app.flags.DEFINE_integer(
tensorflow.app.flags.DEFINE_integer
14,721
import tensorflow as tf """Define a single cell with variational dropout""" def get_a_cell(state_size,input_prob,state_prob,num_input): if cell_type == 'LSTM': if activation == 'linear': lstm=tf.nn.rnn_cell.LSTMCell(num_units=state_size, activation = tf.identity, state_i...
tensorflow.nn.rnn_cell.LSTMCell
14,722
import tensorflow as tf g = tf.gradients(U, x, grad_ys=self.dummy_x1_tf)[0] return tf.gradients(g, self.dummy_x1_tf)[0]
tensorflow.gradients
14,723
import tensorflow as tf * Qingyao Ai, Keping Bi, Cheng Luo, Jiafeng Guo, W. Bruce Croft. 2018. Unbiased Learning to Rank with Unbiased Propensity Estimation. In Proceedings of SIGIR '18 """ def __init__(self, data_set, exp_settings, forward_only=False): """Create the model. Args:...
tensorflow.contrib.training.HParams
14,724
import tensorflow as tf callback.on_rollout_start() if step % self.update_buffer_interval ==0 and step>self.learning_starts: mean_agent = sum(all_r)/sum(all_r_step) mean_exp = sum(all_exp_r)/sum(all_exp_r_step) add_r = me...
tensorflow.Summary.Value
14,725
import tensorflow as tf rnn_params, base_variable_scope="Model/RNN") tf.add_to_collection(tf.GraphKeys.SAVEABLE_OBJECTS, params_saveable) self._cost = tf.get_collection_ref(util.with_prefix(self._name, "cost"))[0]
tensorflow.add_to_collection
14,726
import tensorflow as tf return tf.reduce_mean(loss) loss = tf.map_fn(fn=lambda inp: sample_compute(inp), elems=tf.range(resample), dtype=tf.float32, parallel_iterations=32) final_loss = tf.reduce_mean(loss) return final_loss def contra_traj_lossV1(pred, tgt, temp=10.0):...
tensorflow.reduce_mean
14,727
import tensorflow as tf pred_mat = tf.get_variable('pred_mat', [in_size, self._out_vocab_size]) pred_bias = tf.get_variable('pred_bias', [self._out_vocab_size]) # Make a prediction for each tweet. def GetWordPred(o_): logits = tf.nn.xw_plus_b(o_, pred_mat, pred_bias) return tf.nn.softmax(l...
tensorflow.nn.softmax
14,728
import tensorflow as tf def train_rnn_multi(raw_data_x, raw_data_y, val_data_x, val_data_y, timeindex_train, timeindex_val, g, num_epochs, num_steps, batch_size, input_prob, output_prob, state_prob, epoch_before_val = 50, max_checks_without_progress=50,epoch_overlap=None, verbose=True, save=False): with tf.Sess...
tensorflow.Session
14,729
import tensorflow as tf examples_per_sec = num_epochs * num_batches * batch_size / wall_time self.report_benchmark( name="eager_train_%s" % ("gpu" if tfe.num_gpus() > 0 else "cpu"), iters=num_epochs * num_batches, extras={"examples_per_sec": examples_per_sec}, ...
tensorflow.test.main
14,730
import tensorflow as tf Args: var_name: name of variable as a string. """ if var_name not in self._initializers: if var_name == self.GAMMA: self._initializers[self.GAMMA] = tf.ones_initializer() elif var_name == self.BETA: self._initializers[self.BETA] = tf.zeros_initiali...
tensorflow.zeros_initializer
14,731
import tensorflow as tf n_neg_to_select = tf.cast(params['negative_ratio'] * n_positives, tf.int32) n_neg_to_select = tf.minimum(n_neg_to_select, tf.cast(n_negtives, tf.int32))
tensorflow.cast
14,732
import tensorflow as tf """ max_time = 8 batch_size = 16 inputs = tf.random_uniform([batch_size, max_time], maxval=30521, dtype=tf.int32)
tensorflow.random_uniform
14,733
from tensorflow.python.ops import random_ops else: gradient_shape = gradient.get_shape() noise = random_ops.truncated_normal(gradient_shape) * gradient_noise_scale noisy_gradients.append(gradient + noise)
tensorflow.python.ops.random_ops.truncated_normal
14,734
from tensorflow.core.framework import op_def_pb2 as _op_def_pb2 path_values: A `Tensor` of type `float32`. name: A name for the operation (optional). Returns: A `Tensor` of type `float32`. """ result = _op_def_lib.apply_op("UnpackPath", path=path, path_values=path_val...
tensorflow.core.framework.op_def_pb2.OpList
14,735
import tensorflow as tf by mistake. """ def fun_(*args, **kwargs): try: return fun(*args, **kwargs) except ValueError as e: if 'reuse' in str(e): with tf.variable_scope(tf.get_variable_scope(), reuse=True): return fun(*args, **kwar...
tensorflow.get_variable_scope
14,736
import tensorflow as tf min_score_thresh=0.65, min_iou_thresh=0.5, is_class_agnostic=False) nms_masks_expected2 = tf.stack([mask2, mask0, mask5, mask4]) nms_scores_expected2 = tf.constant([0.95, 1.0, 0.8, 0.7], dtype=tf.float32) nms_classes_expected2 = tf.constant([0, 1, 2, 2], d...
tensorflow.constant
14,737
import tensorflow as tf else: return -tf.reduce_sum(log_sum_exp(log_probs), [1, 2]) def mse_loss(pred, labels): try: batch_size = tf.cast(pred.shape[0], tf.float32) except Exception as e: print('Pred is a tf tensor %s' % str(e.message)) batch_size = tf.cast(tf.shape(pred)[0], tf.float32) ...
tensorflow.nn.l2_loss
14,738
import tensorflow as tf x, y_size[:-1], kernel, align_corners=False) resized = tf.nn.conv3d_transpose( value=resized, filter=kernel, output_shape=y_size, strides=[1, 1, 1, 1, 1], ...
tensorflow.nn.bias_add
14,739
import tensorflow as tf td_map[self.train_model.states_ph] = states td_map[self.train_model.dones_ph] = masks td_map[self.polyak_model.states_ph] = states td_map[self.polyak_model.dones_ph] = masks if writer is not None: # run loss backprop with summ...
tensorflow.RunOptions
14,740
import tensorflow as tf "target_action": tf.zeros( obs_shape[:1] + [num_target_frames, 1], dtype=tf.int32), "target_reward": tf.zeros( obs_shape[:1] + [num_target_frames, 1], dtype=tf.int32), "target_policy": tf.zeros( obs_shape[:1] + [num_target_frames] + [action_space....
tensorflow.zeros
14,741
import tensorflow as tf arc_seq = arc_seq.write(start_id + 2 * i, index) curr_log_prob = tf.nn.sparse_softmax_cross_entropy_with_logits(
tensorflow.nn.sparse_softmax_cross_entropy_with_logits
14,742
from tensorflow.keras.layers import Dense, Conv2D, MaxPool2D, Flatten # Block 1 conv1a = Conv2D(padding="same", filters=RNN_SIZE//8, kernel_size=[8, 8], strides=4, data_format='channels_last', kernel_initializer=w_init,activation=tf.nn.relu)(self.inputs) conv1b = Conv2D(padding="same", filters=RNN_SIZE//...
tensorflow.keras.layers.Conv2D
14,743
import tensorflow as tf def dense(x, num_units, scope="dense", training=True, ema=None, init=False, bias_initializer=tf.constant_initializer(0.)): with tf.variable_scope(scope):
tensorflow.constant_initializer
14,744
import tensorflow as tf if isinstance(metric, ShapeAccuracyMetric): labels = sample['shapes'] weights = tf.math.sign(labels + 1) # -1 is mapped to zero, else 1 metric.update(labels, detections['shapes_logits'], weights) elif isinstance(metric, BoxIoUMetric): scene_id = str(...
tensorflow.reshape
14,745
import tensorflow as tf from tensorflow.contrib.tensorboard.plugins import projector from Bunch import Bunch tf.app.flags.DEFINE_string('input_path', '../data/tmp/grid03.14.c.tar.gz', 'input folder') tf.app.flags.DEFINE_string('input_name', '', 'input folder') tf.app.flags.DEFINE_string('test_path', '', 'test set fo...
tensorflow.app.flags.DEFINE_string
14,746
import tensorflow as tf # Gain bias bias_shape = [1, 1, 1, 1, self.hgru_k[idx]] if self.gate_bias_init == 'chronos': bias_init = -tf.log( tf.random_uniform( bias_shape, mi...
tensorflow.get_variable
14,747
import tensorflow as tf print('\rTrained in %.3fs. Global step %i' % (time() - start, step+1)) return summary class PPO_HC(PPO): def build_anet(self, state_in, name, reuse=False): reg = tf.contrib.layers.l2_regularizer(1e-3) with tf.variable_scope(name, reuse=reuse): l...
tensorflow.layers.dense
14,748
import tensorflow as tf REPLACE_ITER_C = 1500 MEMORY_CAPACITY = 200000 BATCH_SIZE = 32 DISPLAY_THRESHOLD = 100 # display until the running reward > 100 DATA_PATH = './data' LOAD_MODEL = False SAVE_MODEL_ITER = 100000 RENDER = False OUTPUT_GRAPH = False ENV_NAME = 'BipedalWalker-v2' GLOBAL_STEP = tf.Variable(0, train...
tensorflow.train.exponential_decay
14,749
import tensorflow as tf def build_value(self, _input): with tf.variable_scope('VF'): hidden = tf.layers.dense(inputs=_input, units=self.vf_hidden_size, activation=tf.nn.elu) w = tf.get_variable("weights", (se...
tensorflow.stop_gradient
14,750
import tensorflow as tf def avg_norm(t): return tf.reduce_mean(tf.sqrt(tf.reduce_sum(tf.square(t), axis=-1))) def gradient_add(g1, g2, param): print([g1, g2, param.name]) assert (not (g1 is None and g2 is None)), param.name if g1 is None: return g2 elif g2 is None: return g1 e...
tensorflow.nn.moments
14,751
import tensorflow as tf def assign_lr(self, session, lr_value): session.run(self._lr_update, feed_dict={self._new_lr: lr_value}) def export_ops(self, name): """Exports ops to collections.""" self._name = name ops = {util.with_prefix(self._name, "cost"): self._cost} if self._is_training: ...
tensorflow.add_to_collection
14,752
import tensorflow as tf @registry.register_model class FeedForwardCategoricalPolicy(PolicyBase): """Feed-forward categorical.""" def body(self, features): observations = features["inputs_raw"] observations = tf.cast(observations, tf.float32) flat_observations = tf.layers.flatten(observations) wit...
tensorflow.layers.flatten
14,753
import tensorflow as tf layer_c2 = tf.layers.dense(layer_c1, 256, tf.nn.relu, kernel_regularizer=reg) vf = tf.layers.dense(layer_c2, 1, kernel_regularizer=reg)
tensorflow.layers.dense
14,754
import tensorflow as tf from tensorflow.python.framework import ops from tensorflow.python.framework import sparse_tensor from tensorflow.python.ops import array_ops from tensorflow.python.ops import gen_sparse_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import sparse_ops class BatchedS...
tensorflow.load_op_library
14,755
import tensorflow as tf # Add weight decay to the loss. We exclude the batch norm variables because # doing so leads to a small improvement in accuracy. loss = cross_entropy + loc_loss + params['weight_decay'] * tf.add_n( [tf.nn.l2_loss(v) for v in tf.trainable_variables() if 'batch_normalizat...
tensorflow.constant
14,756
import tensorflow as tf elif decoder.update_first: output, state = update(state, input_, None, input_symbol) context, new_weights = look(time, output, input_, pos=pos, prev_weights=prev_weights, context=context) if decoder.conditional_rnn: with tf.variable_scope('condi...
tensorflow.argmax
14,757
import tensorflow as tf def evaluate_legendre_polynomial(degree_l: TensorLike, order_m: TensorLike, x: TensorLike) -> TensorLike: degree_l = tf.convert_to_tensor(value=degree_l) order_m = tf.convert_to_tensor(value=order_m) x = tf.convert_to_ten...
tensorflow.equal
14,758
import tensorflow as tf Arguments: Y_labels -- ground truth vector N_classes -- the number of classes in the ground truth vector N_ch -- number of channels, if any (for the feature vector only) Returns: one_hot -- one hot matrix encoding """ # Create a tensot flow constant equal to t...
tensorflow.expand_dims
14,759
import tensorflow as tf with tf.variable_scope('target_q'): self.target_q = R + self.gamma * self.q_ with tf.variable_scope('abs_TD'): self.abs_td = tf.abs(self.target_q - self.q) self.ISWeights = tf.placeholder(tf.float32, [None, 1], name='IS_weights') with tf...
tensorflow.placeholder
14,760
import tensorflow as tf def correlation_loss(source_samples, target_samples, weight, name='corr_loss'): """Adds a similarity loss term, the correlation between two representations. Args: source_samples: a tensor of shape [num_samples, num_features] target_samples: a tensor of shape [num_samples, num_f...
tensorflow.reduce_mean
14,761
import tensorflow as tf q_values_adaptive = q_func(observations_ph.get(), num_actions, scope="adaptive_q_func") perturb_for_adaption = perturb_vars(original_scope="q_func", perturbed_scope="adaptive_q_func") kl = tf.reduce_sum(tf.nn.softmax(q_values) * (tf.log(tf.nn.softmax(q_values)) - tf.log(...
tensorflow.nn.softmax
14,762
from tensorflow.python.platform import gfile self.assertEqual([], save.last_checkpoints) s1 = save.save(sess, os.path.join(save_dir, "s1")) self.assertEqual([s1], save.last_checkpoints) self.assertTrue(gfile.Exists(s1)) s2 = save.save(sess, os.path.join(save_dir, "s2")) self.asser...
tensorflow.python.platform.gfile.Exists
14,763
import tensorflow as tf trainable=True ) self.ch_len = tf.reshape(tf.reduce_sum( tf.cast(tf.cast(self.ch, tf.bool), tf.int32), axis=2), [-1]) self.qh_len = tf.reshape(tf.reduce_sum( tf.cast(tf.cast(self.qh, tf.bool), tf.int32)...
tensorflow.cast
14,764
import tensorflow as tf W_p = self._make_var('W_p', (1, 1, ch_mul * ch, ch)) X = tf.nn.relu(X)
tensorflow.nn.relu
14,765