query
stringlengths
10
2k
document
stringlengths
20
51.2k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Get the main diagonal of a matrix.
def diagonal(matrix): if sp.sparse.issparse(matrix): diag = np.array(matrix.diagonal()) else: diag = np.diagonal(matrix).copy() return diag
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_diagonal(matrix):\n\tdegree_vector = tf.reduce_sum(matrix, 1)\n\tdiagonal = tf.diag(degree_vector, name = 'diagonal')\n\treturn diagonal", "def diagonal(self):\n return self.rep.diagonal()", "def get_off_diagonal(matrix):\n\toff_diag = scipy.array(matrix, dtype=matrix.dtype)\n\toff_diag[scipy.di...
[ "0.7615821", "0.73026854", "0.7159124", "0.6796149", "0.66654295", "0.65582407", "0.6554738", "0.6469641", "0.6464411", "0.6426505", "0.64172024", "0.6412851", "0.63874257", "0.6370052", "0.63545513", "0.6346253", "0.63396114", "0.6335569", "0.6327702", "0.63099086", "0.63057...
0.7441718
1
This functions saves a list of objects to a CSV file
def save_to_file_csv(cls, list_objs): r_fields = ['id', 'width', 'height', 'x', 'y'] s_fields = ['id', 'size', 'x', 'y'] filename = cls.__name__ + ".csv" new_list = [] with open(filename, "w") as fp: if cls.__name__ == "Rectangle": dict_writer = csv.Di...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_to_file_csv(cls, list_objs):\n with open(cls.__name__ + \".csv\", \"w\", newline='') as f:\n if cls.__name__ == \"Rectangle\":\n fieldnames = ['id', 'width', 'height', 'x', 'y']\n elif cls.__name__ == \"Square\":\n fieldnames = ['id', 'size', 'x',...
[ "0.832518", "0.8291802", "0.8218108", "0.81547445", "0.8072216", "0.8056039", "0.74945074", "0.7408136", "0.7343248", "0.7268653", "0.7216006", "0.7210721", "0.71920025", "0.7153399", "0.71036434", "0.7076043", "0.7021828", "0.7017505", "0.7012292", "0.69622785", "0.6956361",...
0.8053882
6
Find unique elements in the array in sorted order
def sorted_distinct(arr: list): arr.sort() sorted_map = {} for i in arr: if i in sorted_map: sorted_map[i] += 1 else: sorted_map[i] = 1 return [i for i in sorted_map.keys()]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unique_of_an_array(an_array):\n temp_array=an_array.copy()\n u=[]\n for i in range(temp_array.shape[0]):\n for j in range(temp_array.shape[1]):\n if temp_array[i][j] not in u:\n u.append(temp_array[i][j])\n return sorted(u)", "def get_uniques(array):\n uniques ...
[ "0.7903974", "0.7811364", "0.7743681", "0.7731417", "0.7559613", "0.73426545", "0.71421504", "0.7133541", "0.70766103", "0.69506234", "0.6938547", "0.69357985", "0.68782777", "0.68355066", "0.6756267", "0.6753778", "0.6745469", "0.67304724", "0.66858006", "0.6607441", "0.6580...
0.71383923
7
vggtrasformer_2 use 16 layers of transformer, for testing purpose, it is too expensive. For fast turnaround test, reduce the number of layers to 3.
def override_config(args): args.transformer_enc_config = ( "((1024, 16, 4096, True, 0.15, 0.15, 0.15),) * 3" )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mtf_transformer2_base():\n hparams = common_hparams.basic_params1()\n\n hparams.add_hparam(\"d_model\", 1024)\n hparams.batch_size = 4\n hparams.max_length = 1024\n hparams.label_smoothing = 0.0\n # a small positive value - this seems important for stability when training\n # with bfloat16 activations.\...
[ "0.6721557", "0.6296487", "0.62341666", "0.61886126", "0.6173103", "0.6112292", "0.6077249", "0.5979762", "0.58964986", "0.58882344", "0.5867929", "0.5854765", "0.5839208", "0.58341473", "0.58229804", "0.5812149", "0.58014244", "0.57912505", "0.57797843", "0.5762676", "0.5748...
0.0
-1
Constructs a MultiHeadedProjectionLayer object.
def __init__(self, params): super().__init__(params) p = self.params feature_axis = 0 if p.is_output_projection else (-2, -1) self.TrackQWeight( 'w', shape=[p.input_dim, p.num_heads, p.dim_per_head], feature_axis=feature_axis, legacy_aqt_weight_name='aqt_w')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make(cls, *args, **kwargs):\n if not args and 'n_repeats' not in kwargs:\n return kwargs.pop('base_block', MultiLayer)(**kwargs)\n return cls(*args, **kwargs)", "def build_sample(self, wavelength=None):\n self.init_materials(wavelength)\n\n multi_layer = ba.MultiLayer()...
[ "0.5952606", "0.5582669", "0.556415", "0.53807557", "0.53745204", "0.5322427", "0.5316789", "0.51862514", "0.5089342", "0.5078979", "0.5074852", "0.5039835", "0.50182056", "0.49782854", "0.4951453", "0.4863627", "0.4862779", "0.486185", "0.485663", "0.48504272", "0.48482642",...
0.0
-1
Constructs a _MultiHeadedAttention object.
def __init__(self, params): super().__init__(params) p = self.params assert p.input_dim, f'input_dim is {p.input_dim}' assert p.hidden_dim, f'hidden_dim is {p.hidden_dim}' assert p.num_heads > 0, f'num_heads is {p.num_heads}' # if proj_tpl does not have dim_per_head set, set it if p.proj_tpl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _MultiHeadedAtten(self, name, num_heads=None,\n enable_qkv_proj_in_onestep=False):\n p = self.params\n if num_heads is None:\n num_heads = p.num_heads\n\n atten_p = MultiHeadedAttention.Params().Set(\n name=name,\n input_dim=p.model_dim,\n hidden_dim=p....
[ "0.6472108", "0.6366916", "0.6293355", "0.6098274", "0.6059254", "0.5628869", "0.5620153", "0.54215986", "0.5290655", "0.5270716", "0.52631223", "0.50996226", "0.50717175", "0.50506586", "0.50473154", "0.49782172", "0.4955711", "0.4954686", "0.48387456", "0.48106182", "0.4797...
0.0
-1
Dot attention function for queries with 1 time step.
def _DotAttenOneStep(self, theta, query, key, value, paddings, segment_mask, per_step_padding=None, time_step=None, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attention(query, step):\n \n if nest.is_sequence(query): # If the query is a tuple, flatten it.\n query_list = nest.flatten(query)\n query = array_ops.concat(query_list, 1)\n _tmp = math_ops.matmul(query, w) + b\n _tmp = array_ops.resha...
[ "0.6625102", "0.662204", "0.619892", "0.60684574", "0.5765027", "0.5762571", "0.5693424", "0.56726426", "0.5619098", "0.560286", "0.5566475", "0.55615497", "0.5554051", "0.5513909", "0.54958737", "0.54841906", "0.54707295", "0.5464318", "0.54422796", "0.54346764", "0.5434371"...
0.5605279
9
For long sequence, directly apply to the entire tensor with padding.
def _LongSeq(): logits = self._AttenLogitsOneStep(theta, query, key, time_step) padded_logits = py_utils.ApplyPadding(pad, logits, GetDtypeMin(logits.dtype)) if p.use_scale_invariant_atten: probs = tf.nn.relu(padded_logits) probs = tf.cast( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pad_collate_fn(batch):\n length = [len(sentence) for sentence in batch]\n return pad_sequence([torch.LongTensor(s) for s in batch], batch_first=True), torch.LongTensor(length)", "def padding_tensor(sequences, max_length=1000000):\n # get the number of sequences\n num = len(sequences)\n # get t...
[ "0.70325106", "0.68451375", "0.65590197", "0.65119994", "0.64863014", "0.6420316", "0.639241", "0.6309983", "0.6296469", "0.62777597", "0.6275663", "0.6241049", "0.6239011", "0.6227006", "0.6182913", "0.6168136", "0.6162722", "0.6145137", "0.61081094", "0.60730654", "0.605333...
0.0
-1
Add RoPE (Rotary Position Embedding) [1] to q/k proj vector.
def _RoPE(self, theta, proj, stride=1, time_step=None): assert self.params.rope_tpl proj_len = py_utils.GetShape(proj)[1] position = tf.range(proj_len)[tf.newaxis, :] * stride if time_step is not None: time_span = proj_len * stride start_time = time_step - time_span + 1 position += sta...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getGraspPoseUsingRodrigues(self, preffered_rotation, rod_vector, object_pose):\n rospy.loginfo('Determining grasping poses using rodrigues rotation')\n \n rodr = self.rodriguesRotation(rod_vector, preffered_rotation, object_pose)\n\n if preffered_rotation[2] < 0:\n pr...
[ "0.5737153", "0.571936", "0.56181306", "0.55259967", "0.5472413", "0.5464584", "0.54324645", "0.53999805", "0.5390981", "0.5388044", "0.53767323", "0.53390855", "0.5336979", "0.5275702", "0.5265656", "0.52191", "0.5212267", "0.51919633", "0.5172878", "0.51635474", "0.5157436"...
0.60834527
0
Constructs a MultiHeadedAttentionXL object.
def __init__(self, params): super().__init__(params) params = self.params assert not params.packed_input, 'Packed input not implemented yet.' assert not params.rope_tpl, 'Relative positional embedding is used.' if params.rel_pos_emb_dim is None or params.rel_pos_emb_dim <= 0: raise ValueErro...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _MultiHeadedAtten(self, name, num_heads=None,\n enable_qkv_proj_in_onestep=False):\n p = self.params\n if num_heads is None:\n num_heads = p.num_heads\n\n atten_p = MultiHeadedAttention.Params().Set(\n name=name,\n input_dim=p.model_dim,\n hidden_dim=p....
[ "0.6157112", "0.591613", "0.58034045", "0.5624724", "0.5232411", "0.5149599", "0.51057684", "0.5060455", "0.49645206", "0.48824126", "0.48439094", "0.48438048", "0.48167497", "0.47339055", "0.473009", "0.47212622", "0.47077736", "0.46389425", "0.45844752", "0.4558108", "0.452...
0.0
-1
Constructs a MultiHeadedAttentionRPE object.
def __init__(self, params): super().__init__(params) params = self.params assert not params.packed_input, 'Packed input not implemented yet.' if not params.rel_pos_radius: raise ValueError('Invalid rel_pos_radius: %s' % params.rel_pos_radius) if params.rel_pos_emb_dim is None: rel_pos...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _MultiHeadedAtten(self, name, num_heads=None,\n enable_qkv_proj_in_onestep=False):\n p = self.params\n if num_heads is None:\n num_heads = p.num_heads\n\n atten_p = MultiHeadedAttention.Params().Set(\n name=name,\n input_dim=p.model_dim,\n hidden_dim=p....
[ "0.62512153", "0.62281233", "0.59298307", "0.5659419", "0.53589463", "0.51942724", "0.5162194", "0.5102436", "0.49161288", "0.48888445", "0.48162606", "0.47987306", "0.4792397", "0.47817773", "0.4732918", "0.47103146", "0.4698781", "0.4695849", "0.46731085", "0.45913684", "0....
0.0
-1
Computes the local attention context vector.
def _AttenContext(self, theta, probs, value): p = self.params # -> [B, U, C, N, H] value_block_context = attention_util.ExtractBlockContext( value, block_size=p.block_size, left_context=p.left_context, right_context=p.right_context) # Compute the attention context vector...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_context(self, input):\n context = self.forward(input)\n return context.squeeze(0).detach().cpu().numpy()", "def local_attention(inputs, num_filters, filter_size=5, initializer=None, reuse=None,\n name=''):\n print(\"Local Attentional\")\n weighted_inputs, _ = co...
[ "0.6113359", "0.60229737", "0.6022344", "0.57348704", "0.5707004", "0.5689684", "0.56253386", "0.5516826", "0.54966545", "0.5473481", "0.5454388", "0.53378606", "0.53173435", "0.5298053", "0.52972806", "0.5230908", "0.5210415", "0.5206691", "0.51949996", "0.5187058", "0.51770...
0.5140997
23
Returns the initial state given the batch size.
def zero_state(self, batch_size): p = self.params if (p.inference_step_max_length is not None and p.inference_step_max_length > 0 and not p.right_context): if p.minimize_state_size: state0 = self._zero_state_static_length_inputs(batch_size) else: state0 = self._zero_state_sta...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_initial_state(self, size):\n return self._lstm_cell.zero_state(size, tf.float32)", "def initial_state(self):\n state = GameState(self.size)\n return state", "def initial_state(self, batch_size, dtype=tf.float32, trainable=False,\n trainable_initializers=None, tra...
[ "0.7947754", "0.7363662", "0.73470986", "0.7291511", "0.71293545", "0.7114751", "0.7112994", "0.7026598", "0.6920046", "0.6772483", "0.67661166", "0.676301", "0.6692351", "0.6677714", "0.66522497", "0.664847", "0.6627122", "0.66012615", "0.65866125", "0.6583333", "0.6575712",...
0.72962725
3
Returns the initial state given the batch size.
def _zero_state_static_length_inputs(self, batch_size): p = self.params assert p.enable_value_proj, 'Value projection must be enabled.' assert p.right_context == 0, 'StreamStep does not support look-ahead' context_len = p.inference_step_max_length + p.left_context - 1 inputs = tf.zeros([batch_size,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_initial_state(self, size):\n return self._lstm_cell.zero_state(size, tf.float32)", "def initial_state(self):\n state = GameState(self.size)\n return state", "def initial_state(self, batch_size, dtype=tf.float32, trainable=False,\n trainable_initializers=None, tra...
[ "0.7947754", "0.7363662", "0.73470986", "0.72962725", "0.7291511", "0.71293545", "0.7114751", "0.7112994", "0.7026598", "0.6920046", "0.6772483", "0.67661166", "0.676301", "0.6692351", "0.6677714", "0.66522497", "0.664847", "0.6627122", "0.66012615", "0.65866125", "0.6583333"...
0.6335588
35
Returns the initial state given the batch size.
def _zero_state_static_length_key_value(self, batch_size): p = self.params assert p.enable_value_proj, 'Value projection must be enabled.' assert p.right_context == 0, 'StreamStep does not support look-ahead' context_len = p.inference_step_max_length + p.left_context - 1 if not p.use_3d_recurrent_s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_initial_state(self, size):\n return self._lstm_cell.zero_state(size, tf.float32)", "def initial_state(self):\n state = GameState(self.size)\n return state", "def initial_state(self, batch_size, dtype=tf.float32, trainable=False,\n trainable_initializers=None, tra...
[ "0.7947754", "0.7363662", "0.73470986", "0.72962725", "0.7291511", "0.71293545", "0.7114751", "0.7112994", "0.7026598", "0.6920046", "0.6772483", "0.67661166", "0.676301", "0.6692351", "0.6677714", "0.66522497", "0.664847", "0.6627122", "0.66012615", "0.65866125", "0.6583333"...
0.59797454
88
Returns the initial state given the batch size.
def _zero_state_dynamic_length(self, batch_size): p = self.params assert p.enable_value_proj, 'Value projection must be enabled.' dtype = py_utils.FPropDtype(p) context_len = p.left_context - 1 + p.right_context per_head_dim = p.hidden_dim // p.num_heads key_state = tf.zeros([batch_size, conte...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_initial_state(self, size):\n return self._lstm_cell.zero_state(size, tf.float32)", "def initial_state(self):\n state = GameState(self.size)\n return state", "def initial_state(self, batch_size, dtype=tf.float32, trainable=False,\n trainable_initializers=None, tra...
[ "0.7947754", "0.7363662", "0.73470986", "0.72962725", "0.7291511", "0.71293545", "0.7114751", "0.7112994", "0.7026598", "0.6920046", "0.6772483", "0.67661166", "0.676301", "0.6692351", "0.6677714", "0.66522497", "0.664847", "0.6627122", "0.66012615", "0.65866125", "0.6583333"...
0.65577126
23
Computes the attention context vector.
def _AttenContext(self, theta, probs, value): p = self.params w = p.chunk_size t = py_utils.GetShape(value)[1] b, _, n, h = py_utils.GetShape(value, 4) # [B, T, N, H] -> [B, T, N*H] -> [B, U, C, N*H] -> [B, U, C, N, H] value_block_context, _ = attention_util.ExtractBlockContextV2( tf.res...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self, encoder_state, context, context_lens):\n attn = self.attention(context, encoder_state.squeeze(0), context_lens)\n return attn", "def _compute_context(self, query):\n query = tf.expand_dims(query, -2)\n Wq = tf.layers.dense(query, self.num_hidden, use_bias=False)\n ...
[ "0.669354", "0.6559225", "0.62909424", "0.6278908", "0.6241297", "0.62149274", "0.6077925", "0.6064725", "0.60474426", "0.6003765", "0.5948111", "0.59277827", "0.5915016", "0.5855269", "0.58123964", "0.5811783", "0.5795635", "0.5795128", "0.57468194", "0.57231337", "0.5695144...
0.6304263
2
Returns the initial state given the batch size.
def zero_state(self, batch_size): del batch_size p = self.params if p.left_context != 1 or p.right_context != 0: msg = ('Streaming implementation of chunkwise attention with left context' 'or right context is not supported yet') raise NotImplementedError(msg) return py_utils.Nes...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_initial_state(self, size):\n return self._lstm_cell.zero_state(size, tf.float32)", "def initial_state(self):\n state = GameState(self.size)\n return state", "def initial_state(self, batch_size, dtype=tf.float32, trainable=False,\n trainable_initializers=None, tra...
[ "0.7947754", "0.7363662", "0.73470986", "0.72962725", "0.7291511", "0.71293545", "0.7114751", "0.7112994", "0.7026598", "0.6920046", "0.6772483", "0.67661166", "0.676301", "0.6692351", "0.6677714", "0.66522497", "0.664847", "0.6627122", "0.66012615", "0.65866125", "0.6583333"...
0.0
-1
Constructs an instance of RoutingAttention.
def __init__(self, params): super().__init__(params) p = self.params assert p.num_clusters assert p.attention_window assert not p.packed_input clustering_p = p.clustering clustering_p.num_clusters = p.num_clusters clustering_p.num_heads = p.num_heads clustering_p.dim_per_head = p.di...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(\n self,\n attenuator_id: str,\n left_right: Tuple[int, int],\n strand: int,\n reference_sequence: Seq,\n attenuator_type: str,\n termination_type: str,\n gene_id: str\n ):\n\n super().__init__(\n 'attenuator',\n l...
[ "0.5680706", "0.54734737", "0.54672647", "0.530571", "0.52636737", "0.52148974", "0.5186965", "0.5173307", "0.51536274", "0.5152019", "0.5149425", "0.5084295", "0.5040688", "0.4998937", "0.4948915", "0.49453473", "0.49241173", "0.4923192", "0.49220994", "0.49167085", "0.49135...
0.0
-1
Dot attention function for queries with 1 time step. Called from ExtendStep(). Used for selfattention with p.causal_masking is True.
def _DotAttenOneStep(self, theta, query, states, query_paddings, key_paddings, time_step): # [B, 1, N, K] q_dists, _ = self.clustering.FProp(theta.clustering, query) # [B, T, N, K] k_dists = tf.transpose(states.key_dists, [1, 0, 2, 3]) very_large_dist = tf.constant(0.1 * k_di...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attention(query, step):\n \n if nest.is_sequence(query): # If the query is a tuple, flatten it.\n query_list = nest.flatten(query)\n query = array_ops.concat(query_list, 1)\n _tmp = math_ops.matmul(query, w) + b\n _tmp = array_ops.resha...
[ "0.65419996", "0.6358752", "0.6123207", "0.60444355", "0.59748936", "0.59431535", "0.5899601", "0.5877818", "0.5746097", "0.5704381", "0.5664512", "0.5635003", "0.56339693", "0.5624466", "0.56174827", "0.5598237", "0.55672455", "0.5537529", "0.55087054", "0.53993577", "0.5394...
0.6187589
2
Returns an initialized transformer attention parameters.
def _InitAttentionParams(self, atten_tpl): p = self.params if isinstance(p.num_heads, list) != isinstance(atten_tpl, list): raise ValueError('p.num_heads and p.atten_tpl should both be lists ' f'or both scalars for {p.name} num_heads={p.num_heads}.') if isinstance(p.num_heads, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _InitAttentionParams(self, atten_tpl):\n p = self.params\n source_atten_tpls = []\n # Set up each source attention.\n for i in range(p.num_source):\n src_key = 'source_%d' % i\n src_atten = atten_tpl.Copy()\n src_atten = super()._InitAttentionParams(src_atten)\n if isinstance(sr...
[ "0.6796677", "0.63695675", "0.63633305", "0.63588583", "0.632125", "0.6226864", "0.6143171", "0.6140573", "0.613549", "0.60970265", "0.60904384", "0.60904384", "0.6077484", "0.604645", "0.6032453", "0.6012013", "0.598006", "0.5937277", "0.5897942", "0.5846818", "0.5828533", ...
0.66029155
1
Returns the initial state given the batch size.
def zero_state(self, batch_size=1): p = self.params dtype = py_utils.FPropDtype(p) if not isinstance(self.atten, list): return py_utils.NestedMap(atten=self.atten.zero_state(batch_size)) query_right = p.atten_tpl[0].right_context // p.atten_tpl[0].query_stride # This is used only if the calle...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_initial_state(self, size):\n return self._lstm_cell.zero_state(size, tf.float32)", "def initial_state(self):\n state = GameState(self.size)\n return state", "def initial_state(self, batch_size, dtype=tf.float32, trainable=False,\n trainable_initializers=None, tra...
[ "0.7947754", "0.7363662", "0.73470986", "0.72962725", "0.7291511", "0.71293545", "0.7114751", "0.7112994", "0.7026598", "0.6920046", "0.6772483", "0.67661166", "0.676301", "0.6692351", "0.6677714", "0.66522497", "0.664847", "0.6627122", "0.66012615", "0.65866125", "0.6583333"...
0.6245625
42
Returns an initialized multisource transformer attention parameters.
def _InitAttentionParams(self, atten_tpl): p = self.params source_atten_tpls = [] # Set up each source attention. for i in range(p.num_source): src_key = 'source_%d' % i src_atten = atten_tpl.Copy() src_atten = super()._InitAttentionParams(src_atten) if isinstance(src_atten, list...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _initialize_parameters(self):\n self.ent_emb = tf.get_variable('ent_emb', shape=[len(self.ent_to_idx), self.k * 2],\n initializer=self.initializer)\n self.rel_emb = tf.get_variable('rel_emb', shape=[len(self.rel_to_idx), self.k * 2],\n ...
[ "0.6033196", "0.60194266", "0.60180366", "0.6014643", "0.59916466", "0.59827936", "0.5979642", "0.5866839", "0.5866839", "0.5857028", "0.5844073", "0.5801891", "0.57608277", "0.57513344", "0.57349604", "0.57171535", "0.5658559", "0.56529087", "0.56529087", "0.5643062", "0.562...
0.7509876
0
Transformer decoder layer, extend one step in autoregressive decoding. query_vec and aux_ may have different batch sizes, e.g., during a beam search. target_batch must be a multiple of source_batch and query_vec[i batch_multiplier + j] corresponds to aux_vec[i], where batch_multiplier = target_batch / source_batch, 0 <...
def ExtendStep(self, theta, query_vec, aux_vec, aux_paddings, cached_states, time_step, use_short_seq_opt=False, per_step_padding=None, *, compute_att...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def translate(self, src, max_decode_len=2):\n eos = self.src_dict.get_eos()\n bos = self.src_dict.get_bos()\n gpu = src.is_cuda\n # encode\n emb = self.src_embeddings(src)\n enc_outs, enc_hidden = self.encoder(emb)\n # decode\n dec_hidden = self.decoder.init_...
[ "0.62944573", "0.62526596", "0.6072097", "0.5919257", "0.5884283", "0.58284694", "0.5818037", "0.5810508", "0.58081734", "0.5783295", "0.57722807", "0.573484", "0.57344943", "0.56883526", "0.5670014", "0.5658791", "0.5615382", "0.5575172", "0.55678684", "0.5563763", "0.554250...
0.6168519
2
Uses transformerxl attention for self attention of a transformer layer.
def UseRelativeAttentionInTransformerLayer(transformer_params, rel_pos_emb_dim, atten_type=ATTEN_TRANSFORMER_XL): if not issubclass(transformer_params.cls, TransformerLayer): raise ValueError('Unsupported input transformer layer...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_attention(self, X):\n if self.bn:\n layer = 16\n else:\n layer = 14\n inputs = [K.learning_phase()] + [self.model.inputs[0]]\n _attention_f = K.function(inputs, [\n self.model.layers[layer].output])\n \n return _attention_f([0] + [X...
[ "0.6319565", "0.62168854", "0.6184282", "0.6093936", "0.60388887", "0.59601223", "0.59315914", "0.58853483", "0.5854211", "0.5738924", "0.57165545", "0.564664", "0.5629153", "0.56258667", "0.5595983", "0.5560633", "0.5547885", "0.55398947", "0.5533864", "0.5482042", "0.548202...
0.6025473
5
Construct iith layer params.
def _LayerParams(ii): if isinstance(p.transformer_layer_params_tpl, list): factor = p.num_layers // len(p.transformer_layer_params_tpl) i = ii // factor p_ii = p.transformer_layer_params_tpl[i].Copy() else: p_ii = p.transformer_layer_params_tpl.Copy() p_ii.name = 'layer...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(self):\n\n\t\tparameters = {}\n\t\tL = len(self.layer_dims) # number of layers in the network\n\n\t\tfor l in range(1, L):\n\t\t\tparameters['W' + str(l)] = np.random.randn(self.layer_dims[l], self.layer_dims[l-1]) * 0.01\n\t\t\tparameters['b' + str(l)] = np.zeros((self.layer_dims[l], 1))\n\n\t\t\t...
[ "0.64043915", "0.63688374", "0.6348409", "0.62991357", "0.6247028", "0.6244664", "0.62161946", "0.619899", "0.61678874", "0.6166454", "0.6158457", "0.61472636", "0.6118186", "0.6098291", "0.6097087", "0.6085639", "0.6079641", "0.6079641", "0.60755986", "0.6074832", "0.6052821...
0.72804546
0
Transformer decoder layer, extend one step in autoregressive decoding.
def ExtendStep(self, theta, query_vec, aux_vec, aux_paddings, cached_states, time_step, use_short_seq_opt=False, **kwargs): p = self.params with tf.name_scope(p.name): up...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _define_decoder(self):\n self.decoder = nn.Sequential(nn.Linear(self.encoding_shape, 256), # B, 256\n View((-1, 256, 1, 1)), # B, 256, 1, 1\n nn.SELU(),\n nn.ConvTranspose2d(256, 64, 4), # B, 64, 4, 4\n ...
[ "0.6939827", "0.68978864", "0.68928504", "0.6858092", "0.66230065", "0.6500391", "0.64656705", "0.6444427", "0.6443026", "0.64142644", "0.6372102", "0.63560134", "0.62849027", "0.6260407", "0.62468827", "0.62365526", "0.6221457", "0.61904645", "0.61815256", "0.6100051", "0.60...
0.0
-1
Feedforward, residual and layernorm.
def FProp(self, theta, inputs, paddings, task_id=None): p = self.params if p.use_task_ids: if task_id is None: raise ValueError('Must pass task_id if use_task_ids.') inputs_normalized = self.layer_norm.FProp(theta.layer_norm, inputs) if hasattr(self, 'res_proj_layer'): inputs = self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward_pass(self):\n # Compute the support set's mean and var and use these as the moments for\n # batch norm on the query set.\n train_embeddings = self.embedding_fn(self.episode.train_images,\n self.is_training)\n self.train_embeddings = train_embeddings['...
[ "0.6523409", "0.6407294", "0.6303523", "0.62720263", "0.6258788", "0.62392306", "0.620798", "0.6184551", "0.61842686", "0.61518633", "0.6138946", "0.60871845", "0.60689586", "0.6049719", "0.60362995", "0.60171664", "0.60053295", "0.59995836", "0.5982191", "0.59718114", "0.597...
0.0
-1
Replaced dropout layers in transformer with deterministic ones.
def SetupDeterministicDropout(cls, params): params.tr_atten_tpl.dropout_tpl = ( layers.DeterministicDropoutLayer.Params()) params.tr_atten_tpl.atten_tpl.dropout_tpl = ( layers.DeterministicDropoutLayer.Params()) params.tr_fflayer_tpl.residual_dropout_tpl = ( layers.DeterministicDropo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ConvertDropout(converter, serializer, inp, layer_name, parent_layer_name, dropout_ratio):\n\n # Generate a tensor filled with uniform random values..\n # This means tensor value is constant and no random number generation in runtime.\n # This behavior is different from Chainer's one.\n # Chainer us...
[ "0.6178697", "0.59508526", "0.5813365", "0.58066803", "0.5782544", "0.57550555", "0.57477057", "0.56976753", "0.5696417", "0.56752086", "0.5672088", "0.5666318", "0.56533575", "0.56506664", "0.56465274", "0.5631444", "0.56067914", "0.55928016", "0.55619615", "0.5543121", "0.5...
0.61844414
0
Transformer decoder layer, extend one step in autoregressive decoding.
def ExtendStep(self, # pytype: disable=signature-mismatch theta, query_vec, aux_vec, aux_paddings, cached_states, time_step, use_short_seq_opt=False): target_batch, _, dim = py_utils.GetShape(quer...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _define_decoder(self):\n self.decoder = nn.Sequential(nn.Linear(self.encoding_shape, 256), # B, 256\n View((-1, 256, 1, 1)), # B, 256, 1, 1\n nn.SELU(),\n nn.ConvTranspose2d(256, 64, 4), # B, 64, 4, 4\n ...
[ "0.6939827", "0.68978864", "0.68928504", "0.6858092", "0.66230065", "0.6500391", "0.64656705", "0.6444427", "0.6443026", "0.64142644", "0.6372102", "0.63560134", "0.62849027", "0.6260407", "0.62468827", "0.62365526", "0.6221457", "0.61904645", "0.61815256", "0.6100051", "0.60...
0.0
-1
A lightweight conv block followed by a feedforward one.
def LconvBlock(self, name, kernel_size, is_causal, convolution_fn): return self._Seq( name, self.LConv( name='lconv', kernel_size=kernel_size, is_causal=is_causal, convolution_fn=convolution_fn), self.Feedforward('ff', is_causa...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conv_block(self, output_channel, filter_, activate):\n return self.add_layer(conv_block, output_channel, filter_, activate)", "def conv_block(input, filters, phase=phase):\r\n\r\n conv_block = tf.layers.conv2d(\r\n inputs=input,\r\n filters=filters,\r\n kernel_s...
[ "0.7272312", "0.6646322", "0.6564444", "0.6556552", "0.6520027", "0.65018886", "0.64270085", "0.6384178", "0.63812923", "0.633252", "0.6330558", "0.63254523", "0.6269793", "0.62648326", "0.62648326", "0.62648326", "0.62641525", "0.62562466", "0.62562466", "0.6245282", "0.6236...
0.0
-1
Returns a stack of sequential layers.
def Seq(self, name, *subs): return self._Seq(name, *subs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stack(self):\n # Fetch the zeroth layer data, which is the original input\n \tdata = self.data_container[0]\n # Initialize network that will contain the stack\n \tself.init_stacked_net(data)\n # Add the weights layer by layer from the individual networks.\n \t# The weights contain...
[ "0.6646111", "0.6507411", "0.6507411", "0.6442012", "0.64067453", "0.63617814", "0.62849975", "0.61989015", "0.61201066", "0.6119051", "0.6083303", "0.6041437", "0.59433055", "0.59354025", "0.5891355", "0.5862278", "0.58168966", "0.58028525", "0.57797754", "0.57793665", "0.57...
0.0
-1
Returns a stack of LConv layers with kernel size in kernel_sizes.
def LConvStack(self, name, kernel_sizes, is_causal=False): blocks = [] for i, kernel_size in enumerate(kernel_sizes): blocks.append( self.LconvBlock( name='block_{}'.format(i), kernel_size=kernel_size, is_causal=is_causal, convolution_fn=No...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def infer_kernel_sizes(h_sizes):\n kernel_sizes = copy(h_sizes)\n kernel_sizes.pop(-1) # pop last because it is the output of the last CNN layer\n kernel_sizes.insert(0, input_size) # the first kernel size should be (cnn_win_size, input_size)\n kernel_sizes = [(self.cnn_...
[ "0.637894", "0.60106134", "0.5873648", "0.58258736", "0.5763928", "0.5685017", "0.56601936", "0.5637939", "0.5586012", "0.5430046", "0.5424548", "0.5365884", "0.5354758", "0.5321201", "0.53209114", "0.5317806", "0.52309895", "0.52068096", "0.519367", "0.51892775", "0.51716596...
0.7490939
0
Computes self attention with optional stride.
def _StridedAttention(self, name, stride=1, first_n=None, num_heads=None): p = self.params input_to_add = ('i.vec' if p.selfatten_add_unnormalized_input else 'after_ln') attention_inputs = 'strided_query,after_ln,after_ln,i.paddings' sub_list = [] if p.packed_input: if str...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _FunnelAttention(self, name, stride=1, first_n=None, num_heads=None):\n p = self.params\n\n if p.selfatten_add_unnormalized_input:\n shortcut_sub = ('i.vec->strided_input',\n self._Pool('shortcut_after_pooling', stride, first_n))\n else:\n # Reuse 'strided_query' to avoi...
[ "0.6555284", "0.6495866", "0.64859", "0.6378394", "0.63215667", "0.610515", "0.60691375", "0.6063063", "0.60290396", "0.58952874", "0.58887595", "0.587537", "0.56589955", "0.5644497", "0.5594382", "0.55808055", "0.55512404", "0.55327785", "0.55315185", "0.55244154", "0.550900...
0.5979852
9
Computes self attention with optional stride.
def _FunnelAttention(self, name, stride=1, first_n=None, num_heads=None): p = self.params if p.selfatten_add_unnormalized_input: shortcut_sub = ('i.vec->strided_input', self._Pool('shortcut_after_pooling', stride, first_n)) else: # Reuse 'strided_query' to avoid doing the ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def self_attention(self, hidden):\n mul1 = self.attention1(hidden)\n mul2 = self.attention2(mul1)\n return self.softmax(mul2)", "def forward(self,\n state,\n encoder_out=None,\n encoder_padding_mask=None,\n incremental_state=None,\n...
[ "0.6495866", "0.64859", "0.6378394", "0.63215667", "0.610515", "0.60691375", "0.6063063", "0.60290396", "0.5979852", "0.58952874", "0.58887595", "0.587537", "0.56589955", "0.5644497", "0.5594382", "0.55808055", "0.55512404", "0.55327785", "0.55315185", "0.55244154", "0.550900...
0.6555284
0
Returns a stack of sequential layers.
def Stack(self, name, blocks, output_all_layer_hiddens=False): if output_all_layer_hiddens: graph_inputs = ['input'] graph_outputs = [] graph_modules = [] layer_input = 'input' for idx, block in enumerate(blocks): layer_output = 'output_{}'.format(idx) graph_modules.app...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stack(self):\n # Fetch the zeroth layer data, which is the original input\n \tdata = self.data_container[0]\n # Initialize network that will contain the stack\n \tself.init_stacked_net(data)\n # Add the weights layer by layer from the individual networks.\n \t# The weights contain...
[ "0.6646111", "0.6507411", "0.6507411", "0.6442012", "0.64067453", "0.63617814", "0.62849975", "0.61989015", "0.6119051", "0.6083303", "0.6041437", "0.59433055", "0.59354025", "0.5891355", "0.5862278", "0.58168966", "0.58028525", "0.57797754", "0.57793665", "0.57315296", "0.57...
0.61201066
8
Returns a stack of num_layers selfattention layers.
def TransformerEncoderStack(self, name, num_layers=1): blocks = [ self.TransformerEncoderLayer(name='iter_{:0>3d}'.format(d)) for d in range(num_layers) ] return self.Stack(name, blocks)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num_layers(self):\n\n return 2 + self.num_hidden_layers", "def num_layers(self): # -> int:\n ...", "def num_layers(self):\n return self._num_layers", "def layers(self) ->Optional[nn.ModuleList]:\n return self._layers", "def layers(self):\n return self['layers']", "d...
[ "0.61573666", "0.61095876", "0.60311306", "0.59710306", "0.5808267", "0.5741225", "0.57042414", "0.56690127", "0.5668113", "0.56469107", "0.55970293", "0.5569175", "0.55582494", "0.55358714", "0.5493534", "0.54911095", "0.5476597", "0.5473635", "0.54458505", "0.5374401", "0.5...
0.59610206
4
Computes self attention with optional stride.
def _Attention(self, name, is_causal=True): p = self.params tr_atten_p = TransformerAttentionLayer.Params().Set( name='transformer_atten', input_dim=p.model_dim, hidden_dim=p.attention_hidden_dim or p.model_dim, is_masked=is_causal, num_heads=p.num_heads, residual...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _FunnelAttention(self, name, stride=1, first_n=None, num_heads=None):\n p = self.params\n\n if p.selfatten_add_unnormalized_input:\n shortcut_sub = ('i.vec->strided_input',\n self._Pool('shortcut_after_pooling', stride, first_n))\n else:\n # Reuse 'strided_query' to avoi...
[ "0.6555284", "0.6495866", "0.64859", "0.6378394", "0.63215667", "0.610515", "0.60691375", "0.6063063", "0.60290396", "0.5979852", "0.58952874", "0.58887595", "0.587537", "0.56589955", "0.5644497", "0.5594382", "0.55808055", "0.55512404", "0.55327785", "0.55315185", "0.5524415...
0.5272429
52
Read and yield groups of chunks from a buffered file object at offset. Reads never span accros chunksize boundaries.
def file_sync_read_chunks(radosobject, chunksize, nr, offset=0): radosobject.seek(offset * chunksize) while nr: remains = chunksize chunk = '' while 1: s = radosobject.sync_read(remains) if not s: if chunk: yield chunk ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _read_in_chunks(self, file_object, blocksize=4096, chunks=-1,\n shard_index=None):\n i = 0\n while chunks:\n data = file_object.read(blocksize)\n if not data:\n break\n yield data\n i += 1\n\n chunks -= 1...
[ "0.7819766", "0.75124425", "0.7497187", "0.7401726", "0.7370987", "0.73118114", "0.73012", "0.73012", "0.73012", "0.73012", "0.7289257", "0.72518444", "0.72270066", "0.720751", "0.71963775", "0.71630985", "0.71477693", "0.7115037", "0.7115037", "0.71140784", "0.7107615", "0...
0.7551578
1
Given a list (of numbers), returns its median value.
def get_median(values_list): try: for item in values_list: assert isinstance(item, Number) except AssertionError: return 0 values_list.sort() list_len = len(values_list) if list_len < 1: # Mathematically bogus, but will make graph display correctly. medi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_median(numlist):\n return np.median(numlist)", "def median(input_list):\n input_list_len = len(input_list)\n input_list_sorted = sorted(input_list)\n return (sum(input_list_sorted[input_list_len // 2 - 1:input_list_len // 2 + 1]) / 2.0,\n input_list_sorted[input_list_len // 2])[inp...
[ "0.89303535", "0.85163736", "0.8461471", "0.84213775", "0.84156793", "0.8336772", "0.83012617", "0.82465017", "0.82376665", "0.82037026", "0.8174654", "0.8051326", "0.8030004", "0.8003122", "0.7988333", "0.79733235", "0.79012954", "0.78814423", "0.78733206", "0.78258556", "0....
0.85888755
1
return the list of observation probability
def list(self): return self._observe_list
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def probabilities(self):\n raise NotImplementedError", "def probs(self) -> List:\n return self._probs", "def _get_selection_probabilities(self):\r\n probabilities = np.arange(1, self.population_size+1, dtype=float)[::-1]\r\n probabilities /= probabilities.sum()\r\n return pro...
[ "0.7424971", "0.71938646", "0.6812858", "0.6793483", "0.67370343", "0.6686511", "0.66088116", "0.6546532", "0.6533282", "0.6521631", "0.6484366", "0.6420551", "0.6398475", "0.6387996", "0.63872427", "0.63432807", "0.632683", "0.6326216", "0.6323069", "0.63152546", "0.63087815...
0.0
-1
Apply the "add" operation between "self" and "y".
def add( self, y: Union[int, float, np.ndarray, torch.tensor, MPCTensor] ) -> MPCTensor: res = self.__apply_op(y, "add") return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add(self, y):\n return circuit.add(self, y)", "def add(self, x, y):\n pass", "def add_y(self, y, add):\n return (y + add) % self.y_len", "def __iadd__(self, other):\n self.x += other.x\n self.y += other.y\n return self", "def __radd__(self, y):\n for key...
[ "0.79193604", "0.7689266", "0.7479513", "0.7461359", "0.7455734", "0.7385977", "0.71517766", "0.7142252", "0.7131648", "0.7127012", "0.712218", "0.7048276", "0.7048276", "0.69799787", "0.6965129", "0.69572747", "0.693966", "0.69143766", "0.68959343", "0.6887691", "0.68675226"...
0.7799209
1
Returns 3 input tensors
def input_tesors(image_shape, n_classes): tensor_x = tf.placeholder( tf.float32, [None, image_shape[0], image_shape[1], image_shape[2]], name='x' ) tensor_y = tf.placeholder( tf.float32, [None, n_classes], name='y' ) tensor_keep_prob = tf.placeholder( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def three_different_tensor_images():\n rgb1, rgb2, rgb3 = three_different_np_images()\n\n timg1 = torch.tensor(rgb1).reshape(32*32, 3).transpose(1,0).reshape(3,32,32)\n timg2 = torch.tensor(rgb2).reshape(32*32, 3).transpose(1,0).reshape(3,32,32)\n timg3 = torch.tensor(rgb3).reshape(32*32, 3).transpose(...
[ "0.72408676", "0.64934456", "0.64552975", "0.63807607", "0.6287848", "0.62622434", "0.61871564", "0.61838317", "0.6124529", "0.609407", "0.6090002", "0.60861605", "0.6023146", "0.6021901", "0.5996502", "0.58936256", "0.5876906", "0.58656305", "0.58577085", "0.58488345", "0.58...
0.57681143
26
Applies convolution with relu activation and max pooling to x_tensor
def layer_conv2d_maxpool( x_tensor, conv_num_outputs, conv_ksize, conv_strides, pool_ksize, pool_strides ): weights = tf.Variable( tf.random_normal( [ conv_ksize[0], conv_ksize[1], x_tensor.get_shape(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conv2d_maxpool(x_tensor, conv_num_outputs, conv_ksize, conv_strides, pool_ksize, pool_strides):\n # TODO: Implement Function\n #print(\"x_tensor: {} \\nconv_num_outputs: {} \\nconv_ksize: {} \\nconv_strides: {}\" .format(x_tensor, conv_num_outputs, conv_ksize, conv_strides))\n #print(\"pool_ksize: {} ...
[ "0.73637694", "0.73303884", "0.732742", "0.72830814", "0.7275616", "0.72481406", "0.72481406", "0.70267165", "0.70154786", "0.6935409", "0.6928858", "0.6926225", "0.6883792", "0.6867685", "0.68535185", "0.6821788", "0.6814065", "0.6809108", "0.6804984", "0.68045914", "0.67708...
0.674979
22
Flattens x_tensor to (Batch Size, Flattened Image Size)
def layer_flatten(x_tensor): return tf.reshape( x_tensor, [-1, (x_tensor.shape[1] * x_tensor.shape[2] * x_tensor.shape[3]).value] )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def flatten(x_tensor):\n # TODO: Implement Function\n b, w, h, d = x_tensor.get_shape().as_list()\n img_size = w * h * d\n return tf.reshape(x_tensor, [-1, img_size])", "def flatten(self, x_tensor):\n shape = x_tensor.get_shape().as_list()\n assert len(shape) >= 4, 'shape of image is no...
[ "0.8456649", "0.83268803", "0.8092472", "0.80912507", "0.7961118", "0.7939979", "0.7873123", "0.7873123", "0.78406143", "0.78406143", "0.78394294", "0.7741669", "0.73772216", "0.7140569", "0.71365225", "0.7132501", "0.7033926", "0.7030444", "0.6964474", "0.6760298", "0.675469...
0.7890808
6
Applies a fully connected layer with relu activation to x_tensor using weight and bias
def layer_fully_connected(x_tensor, num_outputs): weights = tf.Variable( tf.random_normal( [x_tensor.shape[1].value, num_outputs], stddev=0.1 ) ) bias = tf.Variable(tf.zeros([num_outputs])) return tf.nn.relu( tf.add(tf.matmul(x_tensor, weights), bias) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fully_connect(self, x, w, b, name=\"\"):\n return tf.nn.relu(tf.matmul(x, w) + b, name=name)", "def fully_conn(x_tensor, num_outputs):\n # TODO: Implement Function\n shape = x_tensor.get_shape().as_list()\n weight = tf.Variable(tf.truncated_normal([shape[-1], num_outputs]))\n bias = tf.Var...
[ "0.7154731", "0.70257586", "0.70008355", "0.6943577", "0.692204", "0.6905675", "0.67595243", "0.6757663", "0.6681722", "0.6621531", "0.661753", "0.6616366", "0.6560904", "0.6552978", "0.6541993", "0.6488356", "0.64864564", "0.648009", "0.6456484", "0.6431157", "0.64300513", ...
0.697364
3
Applies an output layer to x_tensor using weight and bias
def layer_output(x_tensor, num_outputs): weights = tf.Variable( tf.random_normal( [x_tensor.shape[1].value, num_outputs], stddev=0.1 ) ) bias = tf.Variable(tf.zeros([num_outputs])) return tf.add(tf.matmul(x_tensor, weights), bias)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def output(x_tensor, num_outputs):\n shape = x_tensor.get_shape().as_list()\n weight = tf.Variable(tf.truncated_normal([shape[-1], num_outputs], stddev=0.1))\n bias = tf.Variable(tf.zeros(num_outputs))\n return tf.add(tf.matmul(x_tensor, weight), bias)", "def output_layer_activation(x):\n return x...
[ "0.74033093", "0.7318695", "0.69349074", "0.68109304", "0.68096894", "0.6716234", "0.67105144", "0.66739506", "0.66238105", "0.65985084", "0.65775484", "0.655952", "0.6543536", "0.645589", "0.64171594", "0.63961196", "0.6387779", "0.63789153", "0.6343245", "0.6333934", "0.633...
0.7349695
1
Get a GraphDef proto from a disk location.
def get_graph_def_from_disk(filename): with gfile.FastGFile(filename, 'rb') as f: return graph_pb2.GraphDef.FromString(f.read())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_graph_def_from_resource(filename):\n return graph_pb2.GraphDef.FromString(resource_loader.load_resource(filename))", "def load_graph_def(filename):\n input_graph_def = tf.GraphDef()\n with gfile.FastGFile(filename, 'rb') as file:\n data = file.read()\n input_graph_def.ParseFromString...
[ "0.73818386", "0.6451315", "0.6279417", "0.6078836", "0.58630353", "0.5862819", "0.5842811", "0.58139306", "0.58132684", "0.57982206", "0.57204235", "0.5713122", "0.55803794", "0.55725914", "0.5559103", "0.5535183", "0.5535183", "0.55274785", "0.5521158", "0.5460929", "0.5458...
0.75813663
0
Get a GraphDef proto from within a .par file.
def get_graph_def_from_resource(filename): return graph_pb2.GraphDef.FromString(resource_loader.load_resource(filename))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_graph_def_from_disk(filename):\n with gfile.FastGFile(filename, 'rb') as f:\n return graph_pb2.GraphDef.FromString(f.read())", "def load_graph_def(filename):\n input_graph_def = tf.GraphDef()\n with gfile.FastGFile(filename, 'rb') as file:\n data = file.read()\n input_graph_def.Pa...
[ "0.67784333", "0.67264247", "0.61706764", "0.6089354", "0.60781455", "0.6025012", "0.59723616", "0.59712183", "0.5930496", "0.5870623", "0.58024126", "0.57894284", "0.57894284", "0.57830846", "0.577333", "0.576531", "0.574869", "0.5668704", "0.565951", "0.56517184", "0.564437...
0.7026078
0
Compute inverse of sigmoid of the input.
def logit(x: torch.Tensor, eps=1e-5) -> torch.Tensor: x = torch.clamp(x, eps, 1.0 - eps) return torch.log(x / (1.0 - x))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inverse_sigmoid(x):\n y = -1 * np.log((1-x)/x)\n return y", "def sigmoid(inX):\n if inX < 0:\n return 1 - 1 / (1 + exp(inX))\n else:\n return 1 / (1 + exp(-inX))", "def sigmoid(x):\n return 1 / (1 + exp(-x))", "def sigmoid(x):\n return 1 / (1 + exp(-x))", "def _sigmoid(x...
[ "0.8370715", "0.7736153", "0.7489325", "0.7489325", "0.7482676", "0.7455829", "0.74328315", "0.741937", "0.7412626", "0.7393388", "0.7393388", "0.7393388", "0.7393388", "0.7393388", "0.7393388", "0.73772293", "0.7368475", "0.7368475", "0.73654795", "0.7365171", "0.73604786", ...
0.0
-1
Convert numpy image (RGB, BGR, Grayscale, SAR, Mask image, etc.) to tensor
def image_to_tensor(image: np.ndarray, dummy_channels_dim=True) -> torch.Tensor: if len(image.shape) not in {2, 3}: raise ValueError(f"Image must have shape [H,W] or [H,W,C]. Got image with shape {image.shape}") if len(image.shape) == 2: if dummy_channels_dim: image = np.expand_dims...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_image_to_tensor(image):\n # image = image.astype(np.float32)\n return transform(image)\n # return transform(image)", "def convert_tensor_to_numpy_img(tensor_img):\n\n img = tensor_img.to('cpu').clone().detach()\n img = img.numpy().squeeze(0)\n img = img.transpose(1, 2, 0)\n img =...
[ "0.79668915", "0.77037525", "0.75477266", "0.74649817", "0.74108833", "0.73693734", "0.73525506", "0.73384076", "0.7241235", "0.71933854", "0.71558005", "0.71321374", "0.7121939", "0.71190095", "0.70590323", "0.7054651", "0.7034931", "0.70309573", "0.7017384", "0.6989768", "0...
0.69051766
23
Convert numpy image (RGB, BGR, Grayscale, SAR, Mask image, etc.) to tensor
def rgb_image_from_tensor( image: torch.Tensor, mean=(0.485, 0.456, 0.406), std=(0.229, 0.224, 0.225), min_pixel_value=0.0, max_pixel_value=255.0, dtype=np.uint8, ) -> np.ndarray: image = np.moveaxis(to_numpy(image), 0, -1) mean = to_numpy(mean) std = to_numpy(std) rgb_image = ma...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_image_to_tensor(image):\n # image = image.astype(np.float32)\n return transform(image)\n # return transform(image)", "def convert_tensor_to_numpy_img(tensor_img):\n\n img = tensor_img.to('cpu').clone().detach()\n img = img.numpy().squeeze(0)\n img = img.transpose(1, 2, 0)\n img =...
[ "0.7966486", "0.77025384", "0.7547711", "0.7464253", "0.74112284", "0.73682314", "0.7353336", "0.73389107", "0.72393113", "0.71921736", "0.71541595", "0.7131128", "0.71219933", "0.71185756", "0.7057919", "0.70554155", "0.7034541", "0.7029281", "0.701752", "0.69898236", "0.697...
0.0
-1
Returns if this objects thread is currently running.
def is_running(self): return self.running
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def running(self):\n try:\n return self._thread.isAlive()\n except (AttributeError, RuntimeError, ThreadError):\n return False", "def is_running(self):\n if self._thread and self._thread.is_alive:\n return True\n\n return False", "def is_running(self...
[ "0.8593505", "0.84121764", "0.82718694", "0.8267202", "0.82653064", "0.82480335", "0.82159096", "0.81916195", "0.8152568", "0.8152568", "0.8131675", "0.8120541", "0.8090041", "0.8058545", "0.8032235", "0.80305076", "0.80305076", "0.80190057", "0.8000695", "0.7996784", "0.7983...
0.80976677
14
Returns if new log entry was logged since last call to this function.
def has_new_entry(self): if self.new_entry: self.new_entry -= 1 return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_new_transaction_log_file(self):\n return self.file_type() == FileType.FILE_TYPE_LOG_NEW", "def is_old_log_edited(self):\n return Gumtree.gumtree.isOldLogEdited()", "def log_once(key):\r\n\r\n global _last_logged\r\n\r\n if _disabled:\r\n return False\r\n elif key not in _lo...
[ "0.6509592", "0.65000105", "0.6278914", "0.6148385", "0.61106443", "0.60488534", "0.5992237", "0.5986473", "0.59745157", "0.5971954", "0.5948575", "0.59472555", "0.5902151", "0.5867795", "0.5860851", "0.5823326", "0.5800767", "0.5785021", "0.57682663", "0.57682663", "0.574859...
0.6248782
3
Return last fetched statuses of accounts. Returns list of {
def get_accounts(self): return self.accounts
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_latest_statuses(self):\n self.status_lock.acquire()\n status = copy.deepcopy(self.cached_status)\n self.status_lock.release()\n return status", "def get_status(self, rows):\n\n\t\taccount_status = {}\n\t\tfor row in rows:\n\t\t\t(account_number, status) = (int(row[0]), row[2])...
[ "0.70284426", "0.6482521", "0.6448589", "0.63747543", "0.6339729", "0.61012065", "0.6072746", "0.60284925", "0.6015464", "0.5953026", "0.59440947", "0.59395874", "0.5933505", "0.5876957", "0.5850216", "0.5839631", "0.5828107", "0.5803067", "0.57647926", "0.57307124", "0.57044...
0.57010156
21
Get field associated with given attribute.
def get_field(self, field_name): for attr_name, field in self: if field_name == attr_name: return field raise errors.FieldNotFound('Field not found', field_name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_field(self, field):\n idx = self._keys.index(field)\n return self._data[idx]", "def model_field_attr(model, field, attr):\n fields = {field.name: field for field in model._meta.fields}\n return getattr(fields[field], attr)", "def get_field(self, field):\n return self._dict.ge...
[ "0.7100779", "0.7038534", "0.6967482", "0.69201434", "0.6890677", "0.668857", "0.6684443", "0.66668856", "0.6486618", "0.64800256", "0.6443001", "0.64064807", "0.63413435", "0.63218987", "0.6318043", "0.6302295", "0.6296515", "0.62962115", "0.62927556", "0.62515414", "0.62308...
0.7119881
0
Add authorization header to requests for APIs without jwt.
def pre_request( self, method: str, url: str, kwargs: Optional[dict] = None, **old_kwargs ): kwargs = kwargs or {} if old_kwargs: warnings.warn( "Keyword argument unpacking is removed in zds-client 2.0.", DeprecationWarning, ) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_header(response):\n response.headers['Authorization'] = response\n return response", "def api_client_authz_header():\n return assemble_authorization_header(API_TOKEN)", "def api_client_authz_header():\n return assemble_authorization_header(API_TOKEN)", "def _addAuthenticationToRequestHead...
[ "0.7161481", "0.70533675", "0.70533675", "0.6826629", "0.6823456", "0.67695475", "0.6748352", "0.6614928", "0.65984744", "0.6570832", "0.65666145", "0.6547807", "0.6534721", "0.6533263", "0.65258455", "0.651365", "0.6504743", "0.6500505", "0.644181", "0.64011186", "0.6388188"...
0.0
-1
Returns true if both objects are equal
def __eq__(self, other): if not isinstance(other, ListEnvInstancesResponse): return False return self.__dict__ == other.__dict__
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self, other):\n return are_equal(self, other)", "def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False", "def __eq__(self, other):\n if i...
[ "0.8088132", "0.8088132", "0.8054589", "0.7982687", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", "0.79670393", ...
0.0
-1
Returns true if both objects are not equal
def __ne__(self, other): return not self == other
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True", "def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)", "def __ne__(self, other) -> bool:\n return not self.__eq__(other)", "def __eq__(self, other):\n ...
[ "0.845611", "0.8391477", "0.8144138", "0.81410587", "0.8132492", "0.8093973", "0.80920255", "0.80920255", "0.80920255", "0.8085325", "0.8085325", "0.8076365", "0.8076365", "0.8065748" ]
0.0
-1
This function calculates the overall_rating of a player based on his position.
def calculate_overall_rating(player_dict): if player_dict["position"].upper() == "QB": throw_power = int(max(min(int(player_dict["throw_power"]), 99), 70)) throw_accuracy = int(max(min(math.ceil( ((2 * ( int(player_dict["throw_accuracy_short"]) + in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def custom_score(game, player):\n \n if game.is_loser(player):\n return float(\"-inf\")\n\n if game.is_winner(player):\n return float(\"inf\")\n\n if game.move_count < 15:\n return center_modified_score(game, player)\n\n own_moves = len(game.get_legal_moves(player))\n opp_mov...
[ "0.66713166", "0.6653607", "0.658866", "0.6550273", "0.6541756", "0.6497867", "0.64732033", "0.6442335", "0.6434981", "0.6423254", "0.64183575", "0.6405612", "0.63906103", "0.6352713", "0.63465255", "0.63366216", "0.632223", "0.6302487", "0.6301581", "0.6292455", "0.62755865"...
0.7758129
0
Returns the components of a polyline.
def proc_polyline(self, tokens): pts = [(p["x"], p["y"]) for p in tokens["points"]] component = Polyline(pen=self.pen, points=pts) return component
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetPolyline(polyline):\r\n pass", "def triangulate(polyline):\n\timport p2t\n\tfrom ynlib.beziers import Point\n\n\t# Convert into p2t Points\n\tfor p in polyline:\n\t\tp = p2t.Point(p.x, p.y)\n\t\n\tcdt = p2t.CDT(polyline)\n\tp2ttriangles = cdt.triangulate()\n\t\n\ttriangles = []\n\tfor t in p2ttrian...
[ "0.7219386", "0.6085877", "0.60215974", "0.60215974", "0.5986118", "0.591302", "0.5875636", "0.5866853", "0.5808601", "0.5796845", "0.578788", "0.57446367", "0.5712954", "0.5666774", "0.5662948", "0.5658937", "0.5648441", "0.5640352", "0.5634172", "0.5584169", "0.55811", "0...
0.7018084
1
Set the IDD to be used by eppy.
def setidd(self, iddinfo, iddindex, block, idd_version): self.idd_info = iddinfo self.block = block self.idd_index = iddindex self.idd_version = idd_version
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def script_set_device(self,udid=None):\n self.desired_caps['udid'] = udid;", "def setiddname(self, iddname, testing=False):\n self.iddname = iddname\n self.idd_info = None\n self.block = None", "def setID(self, idf):\n self.id = idf", "def epid(self, epid):\n\n self....
[ "0.69956744", "0.68834925", "0.63486147", "0.6308923", "0.6308923", "0.6173732", "0.61343026", "0.6103443", "0.6086316", "0.6047241", "0.6046119", "0.5990302", "0.5982955", "0.5944415", "0.5918375", "0.5906082", "0.58837456", "0.586374", "0.5856651", "0.58086425", "0.5790569"...
0.6706148
2
Rounds up to closest `to` number
def roundto(x, to=10.0): if to and not math.isnan(x): return int(round(x / to)) * to else: return x
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def roundAlwaysUp( toRound, end = 10 ):\n\tend = abs( int(end) )\n\n\tif end == 0:\n\t\tend = 10\n\ttimes = toRound/end\n\n\tif times >= 0:\n\t\ttimes = times + 1\n\telse:\n\t\ttimes = times - 1\n\treturn ( int( times ) )*end;", "def roundUP(x):\n\treturn int(ceil(x / 10.0)) * 10", "def roundTo(numberValue, ba...
[ "0.70400405", "0.66403604", "0.65944374", "0.64528203", "0.6366744", "0.6336721", "0.6316938", "0.63095146", "0.6300782", "0.6249121", "0.6200003", "0.61853606", "0.6170838", "0.6169653", "0.6147099", "0.61343104", "0.6116215", "0.6112654", "0.6093039", "0.60832363", "0.60465...
0.70581496
0
Get the serialized dependencies from the GXExecutionEnvironment.
def _get_serialized_dependencies() -> list[dict]: ge_execution_environment = GXExecutionEnvironment() dependencies: list[PackageInfo] = ge_execution_environment.dependencies schema = PackageInfoSchema() serialized_dependencies: list[dict] = [ schema.dump(package_info) for p...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_dependencies_content():\n import trustedanalytics\n dependencies = []\n for filename in trustedanalytics.udf_dependencies:\n name, content = _get_file_content_as_str(filename)\n dependencies.append({'file_name': name, 'file_content': content})\n return dependencies", "def getDep...
[ "0.68384093", "0.66691965", "0.663889", "0.6504829", "0.6416676", "0.63692313", "0.6366625", "0.6057884", "0.6045488", "0.598858", "0.5968873", "0.59633404", "0.59543324", "0.5926851", "0.59149903", "0.58889234", "0.58681244", "0.5845829", "0.5845659", "0.5809698", "0.5807149...
0.834947
0
Query the system and return timezone on RHEL/SL systems
def get_timezone(): try: for line in open('/etc/sysconfig/clock'): field, value = line.split('=') if field.strip() == 'ZONE': return value.replace('"', '').strip() return "" except IOError: return ""
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetAuditedSystemTimezone():\n\n Timezone = False\n try:\n Timezone = os.path.realpath(os.path.join(ROOT_PATH, \"etc/localtime\"))\n Timezone = Timezone.split(\"/\")\n except Exception as e:\n PrintAndLog(u\"Cannot read the timezone\" + str(e.args).decode(\"utf-8\"), \"ERROR\")\n\n...
[ "0.7529804", "0.7272571", "0.7171306", "0.69928813", "0.69601583", "0.68347883", "0.6618945", "0.65921015", "0.65921015", "0.65921015", "0.65921015", "0.65921015", "0.65921015", "0.65921015", "0.65921015", "0.65921015", "0.65921015", "0.65921015", "0.65921015", "0.65921015", ...
0.7475101
1
For a dictionary representation of a graph, returns the number of edges in the graph. Assumes the graph is undirected.
def num_edges(g): total_edges_with_duplicates = sum(len(v) for v in g.values()) return total_edges_with_duplicates // 2
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_num_edges(graph):\n # return the number of edges\n return sum([len(graph[source_node].keys()) for source_node in graph.keys()]) / 2", "def num_edges(self):\n return sum(len(v.adj) for v in self.vertices.values())", "def num_of_edge(self):\n try:\n return self....
[ "0.7951224", "0.71671546", "0.6774145", "0.67708254", "0.67605895", "0.6661372", "0.6651085", "0.66448677", "0.66416717", "0.6641028", "0.6640571", "0.66343987", "0.65923977", "0.65802807", "0.65769345", "0.6542819", "0.6499988", "0.64886355", "0.64821625", "0.64737123", "0.6...
0.7422356
1
Recursively split a path, returns a tuple
def pathsplit(path): stem, basename = os.path.split(path) if stem == '': return (basename,) if stem == path: # fixed point, likely '/' return (path,) return pathsplit(stem) + (basename,)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def splitPath(path):\n return tuple(\n element for element in os.path.split(path.rstrip(os.path.sep)) if element\n )", "def splitpath(path):\n\n # FIXME perhaps call op.split repetitively would be better.\n #s = string.split( path, '/' ) # we work with fwd slash only inside.\n\n#We have decide...
[ "0.8129011", "0.73988", "0.71693224", "0.71135443", "0.7086208", "0.70512766", "0.70502037", "0.70476586", "0.7046054", "0.7016514", "0.70164853", "0.695244", "0.69455993", "0.69291294", "0.6903758", "0.68732667", "0.6841828", "0.6821708", "0.6802932", "0.6760487", "0.6744683...
0.76023793
1
r""" Returns a standard 640x427 image Tensor (RGB, by default) of a bear.
def bear(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor: return imread(HERE+'bear.jpg', target_size=target_size, rgb=rgb)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def guitar(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor:\n return imread(HERE+'guitar.jpg', target_size=target_size, rgb=rgb)", "def template_zone(self):\n ratio = 32\n shape = [self.cam.height, self.cam.width]\n img = self.cam.frame[shape[0] / 2 - 3 * shape[...
[ "0.5820057", "0.56493294", "0.55620486", "0.5541386", "0.5517777", "0.55014724", "0.54683805", "0.5373201", "0.536743", "0.53161746", "0.5299602", "0.52967304", "0.5230648", "0.52244717", "0.51917434", "0.51812625", "0.51736915", "0.5172069", "0.51653844", "0.515548", "0.5108...
0.6954142
0
r""" Returns a standard 640x414 image Tensor (RGB, by default) of a blue tang (a type of fish).
def blue_tang(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor: return imread(HERE+'blue_tang.jpg', target_size=target_size, rgb=rgb)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fighter_fish(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor:\n return imread(HERE+'fighter_fish.jpg', target_size=target_size, rgb=rgb)", "def green_fish(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor:\n return imread(HERE+'green_fish.jpg', target...
[ "0.6450946", "0.63949203", "0.63847965", "0.6338585", "0.61680037", "0.60881", "0.6078518", "0.6056158", "0.60262024", "0.591293", "0.5911401", "0.5827677", "0.5788822", "0.5724372", "0.5680566", "0.56340986", "0.5630523", "0.56091887", "0.56070274", "0.55713695", "0.55630505...
0.7211141
0
r""" Returns a standard 640x358 image Tensor (RGB, by default) of a robotic drone.
def drone(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor: return imread(HERE+'drone.jpg', target_size=target_size, rgb=rgb)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def controller(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor:\n return imread(HERE+'controller.jpg', target_size=target_size, rgb=rgb)", "def mountain(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor:\n return imread(HERE+'mountain.jpg', target_size=ta...
[ "0.60444087", "0.6021321", "0.5779567", "0.5744232", "0.57194453", "0.57190293", "0.55661386", "0.5565801", "0.55503905", "0.54924214", "0.5420223", "0.5241547", "0.5190569", "0.5183966", "0.51816225", "0.5178151", "0.5172133", "0.51606345", "0.5116277", "0.511401", "0.510804...
0.6985907
0
r""" Returns a standard 640x640 image Tensor (RGB, by default) of a fighter fish.
def fighter_fish(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor: return imread(HERE+'fighter_fish.jpg', target_size=target_size, rgb=rgb)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gold_fish(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor:\n return imread(HERE+'gold_fish.jpg', target_size=target_size, rgb=rgb)", "def green_fish(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor:\n return imread(HERE+'green_fish.jpg', target_size=...
[ "0.65156347", "0.63102335", "0.6188329", "0.6089555", "0.58962727", "0.5698029", "0.56924355", "0.55841726", "0.5539289", "0.5483196", "0.547985", "0.5458692", "0.5378748", "0.5371117", "0.5363449", "0.53621924", "0.53405094", "0.53307724", "0.5261794", "0.52340865", "0.52336...
0.765411
0
r""" Returns a standard 640x426 image Tensor (RGB, by default) of an island.
def island(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor: return imread(HERE+'island.jpg', target_size=target_size, rgb=rgb)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def template_zone(self):\n ratio = 32\n shape = [self.cam.height, self.cam.width]\n img = self.cam.frame[shape[0] / 2 - 3 * shape[0] / ratio:shape[0] / 2 + 3 * shape[0] / ratio,\n shape[1] / 2 - 3 * shape[1] / ratio:shape[1] / 2 + 3 * shape[1] / ratio]\n retu...
[ "0.60104334", "0.57679963", "0.5726811", "0.5648886", "0.5482922", "0.54370207", "0.53338945", "0.5310517", "0.5307312", "0.52697843", "0.5244379", "0.5241357", "0.5200629", "0.5199618", "0.51906025", "0.5183777", "0.51695234", "0.51611644", "0.51438767", "0.5120798", "0.5106...
0.69780624
0
r""" Returns a standard 640x427 image Tensor (RGB, by default) of a jellyfish.
def jellyfish(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor: return imread(HERE+'jellyfish.jpg', target_size=target_size, rgb=rgb)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fighter_fish(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor:\n return imread(HERE+'fighter_fish.jpg', target_size=target_size, rgb=rgb)", "def green_fish(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor:\n return imread(HERE+'green_fish.jpg', target...
[ "0.66034675", "0.6507721", "0.63969076", "0.6379017", "0.6297641", "0.6038055", "0.5815378", "0.5796348", "0.5705772", "0.56412405", "0.56362534", "0.5592436", "0.55878234", "0.55784917", "0.55578583", "0.55563915", "0.554843", "0.5525189", "0.5474512", "0.54736805", "0.54588...
0.7425698
0
r""" Returns a standard 640x427 image Tensor (RGB, by default) of a laptop.
def laptop(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor: return imread(HERE+'laptop.jpg', target_size=target_size, rgb=rgb)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tf_pil(self):\n im_w, im_h = self.img.size\n self.orig_width = im_w\n self.orig_height = im_h\n if im_w == self.netw and im_h == self.neth:\n self.scale = None\n self.pad = None\n return self.img\n\n # Rescaling\n if im_w / self.netw >=...
[ "0.56284374", "0.5512475", "0.55074227", "0.5467058", "0.5440016", "0.5398911", "0.5335144", "0.5318327", "0.5316862", "0.53159", "0.52842844", "0.527579", "0.52165836", "0.51971346", "0.5196623", "0.51662767", "0.5148383", "0.51216346", "0.51066744", "0.50635046", "0.5062021...
0.67386276
0
r""" Returns a standard 640x427 image Tensor (RGB, by default) of a red fish.
def red_fish(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor: return imread(HERE+'red_fish.jpg', target_size=target_size, rgb=rgb)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fighter_fish(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor:\n return imread(HERE+'fighter_fish.jpg', target_size=target_size, rgb=rgb)", "def green_fish(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor:\n return imread(HERE+'green_fish.jpg', target...
[ "0.684631", "0.67246217", "0.6447245", "0.6148037", "0.6142723", "0.5998759", "0.5959747", "0.59264976", "0.56356645", "0.56256557", "0.5602238", "0.55696565", "0.55693424", "0.55630165", "0.5556228", "0.5529", "0.5512758", "0.54743516", "0.54735297", "0.54575235", "0.5430131...
0.74174786
0
r""" Returns a standard 640x480 image Tensor (RGB, by default) of a snowflake.
def snowflake(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor: return imread(HERE+'snowflake.jpg', target_size=target_size, rgb=rgb)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def snow(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor:\n return imread(HERE+'snow.jpg', target_size=target_size, rgb=rgb)", "def jellyfish(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor:\n return imread(HERE+'jellyfish.jpg', target_size=target_size,...
[ "0.69219124", "0.596245", "0.5954563", "0.59276724", "0.5676521", "0.5562328", "0.5549815", "0.5548215", "0.55391663", "0.5510637", "0.549667", "0.5468802", "0.5438691", "0.54092693", "0.5373437", "0.5350434", "0.53274757", "0.5277393", "0.5256354", "0.5256015", "0.5241196", ...
0.7511281
0
r""" Returns a standard 640x427 image Tensor (RGB, by default) of a sunrise landscape.
def sunrise(target_size: Optional[Tuple[int, int]] = None, rgb: bool = True) -> Tensor: return imread(HERE+'sunrise.jpg', target_size=target_size, rgb=rgb)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_planet_image(image_path):\n img = Image.open(image_path)\n img_mirror = img.transpose(Image.FLIP_TOP_BOTTOM)\n\n pano = np.asarray(img_mirror)\n\n input_shape = pano.shape\n output_shape = (1080, 1080)\n\n def output_coord_to_r_theta(coords):\n \"\"\"\n Convert co-ordinates in the output image ...
[ "0.5703886", "0.55631506", "0.5472212", "0.545877", "0.5358649", "0.52522165", "0.52238905", "0.5179523", "0.5103584", "0.5103051", "0.5023832", "0.5020596", "0.49851775", "0.4966125", "0.4926159", "0.49248046", "0.4880024", "0.4836553", "0.48247638", "0.48138604", "0.4798284...
0.6839318
0
Terminate the client's session and close this connection.
def exit(self): self.client.logout(self.creds, self.environment) self.transport.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def close_session(self):\n await self._client_session.close()", "def close(self):\n\t\tself._client.close_session()", "def close_connection(self):\n self.session.close()", "def close_connection(self):\n\t\tself.session.close()", "def close(self):\n self.session.close()\n s...
[ "0.79599667", "0.78789794", "0.76926416", "0.75890577", "0.7575554", "0.7513684", "0.7513684", "0.7513684", "0.7513684", "0.7513684", "0.7513684", "0.74137545", "0.74041724", "0.7396674", "0.7344945", "0.7336695", "0.73344606", "0.73344606", "0.73344606", "0.7326345", "0.7326...
0.6682713
73
Yield successive nsized chunks from lst.
def chunks(lst, n): for i in range(0, len(lst), n): yield lst[i:i + n]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chunks(self, lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]", "def chunks(lst: list, n: int):\n for i in range(0, len(lst), n):\n yield lst[i : i + n]", "def chunks(lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]", "de...
[ "0.83071756", "0.81939614", "0.81910837", "0.81910837", "0.8190213", "0.81267184", "0.81218547", "0.81218547", "0.80773693", "0.80526286", "0.80526286", "0.80526286", "0.80526286", "0.80526286", "0.80042696", "0.7871678", "0.7845623", "0.7828392", "0.7827006", "0.78138447", "...
0.80533457
29
Returns Preformatted datetime string of current time
def time_string(date_split: str = '/'): return datetime.now().strftime("%d||%m||%YT%H-%M-%S").replace('||', date_split)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_current_datetime_string ( ) :\n return get_current_datetime( ).strftime( \"%Y%m%d-%H%M%S\" )", "def time_now() -> str:\n return datetime_to_str(datetime_now())", "def current_time():\n now = datetime.datetime.now()\n time = now.strftime(\"%Y-%m-%d %H:%M:%S:%f\")\n return time", "def for...
[ "0.831757", "0.8126042", "0.81231534", "0.8122523", "0.80924016", "0.8082489", "0.79901046", "0.792128", "0.7909241", "0.7899829", "0.78988266", "0.7876332", "0.78625", "0.7850835", "0.78500503", "0.78292924", "0.781112", "0.77286327", "0.76904994", "0.76896113", "0.76805294"...
0.0
-1
Returns the name of the State.
def __str__(self): return self.__class__.__name__
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def state_name(self):\n return self.state.name if self.state else None", "def state_name(self):\n return task_states.to_str(self.state)", "def name(self):\n return self.NAMES[self._mystate]", "def _state_name(self):\n return '{}_{}'.format(self.function_name, self.STATE_CONFIG_SUF...
[ "0.9146206", "0.8559398", "0.83566654", "0.82556134", "0.78584176", "0.7561896", "0.7430628", "0.7430628", "0.7430628", "0.7430628", "0.7430628", "0.7430628", "0.7430628", "0.7430628", "0.7430628", "0.7430628", "0.7430628", "0.7430628", "0.7430628", "0.7430628", "0.7430628", ...
0.0
-1
Story telling function (starts combat with alladin)
def bandit_camp_alladin(): alladin_hum = enemies.alladin_hum() os.system("clear") print("YOU BLOODY BASTARD!! YOU KILLED MY COMRADES!!") time.sleep(1) for i in range(2): print(".") time.sleep(1) print("You won't leave this cave alive! I am Alladin the Prince of Thieves!") ti...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def announce_target(self):\n letter = self.bubbles[self.target].letter\n question = self.load_sound(\"question-\" + letter + \".wav\")\n question.play()\n if android: # get_length() not supported by android.mixer\n ms = 2000 \n else:\n ms = int(question.get...
[ "0.641243", "0.63447523", "0.61562866", "0.61524576", "0.61178875", "0.60670877", "0.6015534", "0.5983124", "0.5967505", "0.5936916", "0.5918603", "0.59173936", "0.59117156", "0.5910987", "0.58863693", "0.58714074", "0.5850372", "0.5841385", "0.5821855", "0.5820761", "0.58111...
0.62644905
2
Tests if missing column raises a ValueError.
def test_missing_column(self, example_dataset): example_dataset = example_dataset.drop(["Sex"], axis=1) transformer = PreprocessFeatures() with pytest.raises(ValueError): transformer.fit_transform(example_dataset)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_run_missing_column(self):\n input_df = self.spark.createDataFrame(\n data=[\n (\"a\",),\n ],\n schema=StructType([\n StructField(\"baz\", StringType()),\n ])\n )\n with raises(AnalysisException):\n se...
[ "0.7638304", "0.7347612", "0.71849775", "0.71579254", "0.7097556", "0.6959807", "0.69370365", "0.6920398", "0.6893228", "0.6852378", "0.66632706", "0.66384923", "0.662511", "0.66015744", "0.6589188", "0.6552241", "0.6531555", "0.6518556", "0.6515614", "0.64755225", "0.6428002...
0.6549609
16
Return all Version Managers.
def get_all_version_manager(_cls=True): queryset = TemplateVersionManager.objects.all() if _cls: queryset = queryset.filter( _cls=TemplateVersionManager._class_name ).all() return queryset
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_template_version_managers(self):\n return type_version_manager_api.get_version_managers_by_user(\n request=self.request\n )", "def get_template_version_managers(self):\n return type_version_manager_api.get_global_version_managers(\n request=self.request\n ...
[ "0.6936819", "0.6910574", "0.6738142", "0.6584001", "0.63497996", "0.611864", "0.6012395", "0.59851784", "0.5890597", "0.5864513", "0.58258367", "0.57849747", "0.5757829", "0.57442814", "0.5723907", "0.570717", "0.570128", "0.56897515", "0.56890506", "0.5674066", "0.5665236",...
0.68620145
2
Given a URL pattern starting ".", ensure that our helper function converts it to the expected format for querying replica databases
def test_split_url_for_query_3(self): url = "*.testurl.com/test" output = split_url_for_query(url) self.assertEqual(output, ("com.testurl.%", "%./test%"))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prepare_url_to_request(url):\n return url\n # get server url from database\n cursor = Database.cursor()\n cursor.execute(\"SELECT url, id FROM servers ORDER BY used_at ASC LIMIT 1\")\n row = cursor.fetchone()\n server_url = row[0]\n identity = row[1]\n # ...
[ "0.59880304", "0.5813885", "0.5746965", "0.5696033", "0.5689914", "0.56774", "0.5612216", "0.5593427", "0.5541081", "0.5539004", "0.5517079", "0.55069524", "0.54813975", "0.5478985", "0.5477902", "0.5477902", "0.5477902", "0.5477902", "0.5477902", "0.5477902", "0.5477902", ...
0.55301183
10
Test that link_is_tracked returns True when we have a matching URLPattern
def test_link_is_tracked_true(self): self.assertTrue(link_is_tracked("https://test.com/testurl"))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_link_is_tracked_true_proxy(self):\n self.assertTrue(\n link_is_tracked(\"https://www-test-com.wikipedialibrary.idm.oclc.org/\")\n )", "def test_link_is_tracked_false(self):\n self.assertFalse(link_is_tracked(\"https://www.foo.com/\"))", "def test_link_is_tracked_true_wi...
[ "0.7802348", "0.77017283", "0.7608935", "0.7507838", "0.73978126", "0.7243416", "0.7057632", "0.6317187", "0.62326664", "0.616892", "0.6121294", "0.6085663", "0.6081502", "0.60433686", "0.60223454", "0.60025805", "0.59855086", "0.5985447", "0.5935883", "0.58979106", "0.587974...
0.84346884
0
Test that link_is_tracked returns True when we have a matching URLPattern even when the link has a subdomain
def test_link_is_tracked_true_with_subdomain(self): self.assertTrue(link_is_tracked("https://foo.test.com/testurl"))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_link_is_tracked_false_not_domain(self):\n self.assertFalse(link_is_tracked(\"https://thisisatest.com/\"))", "def test_link_is_tracked_true(self):\n self.assertTrue(link_is_tracked(\"https://test.com/testurl\"))", "def test_link_is_tracked_true_proxy(self):\n self.assertTrue(\n ...
[ "0.8025488", "0.80175155", "0.7735571", "0.77259254", "0.7386638", "0.71552455", "0.7122597", "0.63324994", "0.6224428", "0.62068295", "0.61544204", "0.6023772", "0.59393805", "0.5937625", "0.589055", "0.58430636", "0.58378404", "0.5821347", "0.5812915", "0.5776888", "0.57758...
0.85889256
0
Test that link_is_tracked returns False when we have no matching URLPattern
def test_link_is_tracked_false(self): self.assertFalse(link_is_tracked("https://www.foo.com/"))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_link_is_tracked_true(self):\n self.assertTrue(link_is_tracked(\"https://test.com/testurl\"))", "def test_link_is_tracked_false_archive(self):\n self.assertFalse(link_is_tracked(\"https://web.archive.org/https://test.com/\"))", "def test_link_is_tracked_false_not_domain(self):\n se...
[ "0.80733407", "0.800625", "0.79449797", "0.7736323", "0.7586259", "0.73005193", "0.7220816", "0.65937287", "0.6507419", "0.64976305", "0.63120306", "0.627331", "0.6235954", "0.61594754", "0.6134132", "0.6108406", "0.60739076", "0.60691065", "0.6064202", "0.60365415", "0.60165...
0.8507864
0
Test that link_is_tracked returns False when we have a partial match based on multiple protocols
def test_link_is_tracked_false_archive(self): self.assertFalse(link_is_tracked("https://web.archive.org/https://test.com/"))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_link_is_tracked_false(self):\n self.assertFalse(link_is_tracked(\"https://www.foo.com/\"))", "def test_link_is_tracked_false_other_proxy(self):\n self.assertFalse(\n link_is_tracked(\"https://www-test-com.university.idm.oclc.org/\")\n )", "def test_link_is_tracked_true(...
[ "0.7855791", "0.7827528", "0.7819036", "0.776752", "0.7544422", "0.72931457", "0.7121497", "0.6005275", "0.5915152", "0.58675873", "0.58453214", "0.57876337", "0.5783955", "0.5721592", "0.5709368", "0.5699607", "0.56930786", "0.5667902", "0.56290555", "0.56232136", "0.5615815...
0.74255633
5
Decode latent input of shape (batch_size, latent_dim) into image of shape (batch_size, n_channels, height, width), scaled between 1 and 1
def decode(self, z): out = self.fc_decoder(z) out = out.view(-1, 512, 2, 2) out = self.decoder(out) return out
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decoder(latent_samples, input_dim, output_dim=500, input_channels=1, output_channels=4, deconv_filters=[4,8,16], \n kernel_sizes=[3,3,3], deconv_strides=[1,1,1], act=tf.nn.relu, \n initializer=tf.contrib.layers.xavier_initializer()):\n x = tf.layers.dense(inputs=latent_samples, units=i...
[ "0.6665639", "0.6241353", "0.61541486", "0.61213005", "0.61125326", "0.6045013", "0.6017717", "0.59589136", "0.59168476", "0.5860372", "0.5828592", "0.5828429", "0.5802362", "0.57738435", "0.57694584", "0.576415", "0.5700526", "0.5698811", "0.5672422", "0.5668072", "0.5654151...
0.0
-1
takes an input of dim (batch_size, n_channels, height, width) returns a reconstruction of shape (batch_size, n_channels, height, width)
def generate(self, x): return self.forward(x)[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _build(self, inputs):\n\n # calculate how many slots we need from the 3 dimensions of the incoming conv layer (filter w/h plus depth)\n dims = inputs.get_shape().as_list()\n new_dim = 1\n for d in dims[1:]: # leave first axis as is (batch)\n new_dim = new_dim * d # mult...
[ "0.6774407", "0.63104725", "0.6274847", "0.62479514", "0.61736107", "0.6162646", "0.6102223", "0.60670877", "0.606563", "0.6007936", "0.59938234", "0.595324", "0.59381884", "0.5938012", "0.5935284", "0.59213746", "0.59169775", "0.59080374", "0.58962864", "0.5888158", "0.58773...
0.0
-1
Computation of precision of the Information Retrieval System at a given value of k for a single query
def queryPrecision(self, query_doc_IDs_ordered, query_id, true_doc_IDs, k): precision = -1 #Fill in code here rel_ret = 0 # no. of relevant docs retrieved for docID in query_doc_IDs_ordered[:k]: if docID in true_doc_IDs: rel_ret += 1 precision = rel_ret/k return precision
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_precision(self, k=None):\n k = 1 if k is None else k\n precisions = []\n \n for query, answer in tqdm(zip(self.test_queries, self.results)):\n correct_set = self.correct_answers[query]\n n_relevant = 0\n for candidate in answer[:k]:\n ...
[ "0.7379347", "0.7302667", "0.70816433", "0.6960076", "0.6946968", "0.69190645", "0.6718051", "0.6696167", "0.6660867", "0.6650946", "0.6597183", "0.65075034", "0.6481797", "0.6455085", "0.6331046", "0.63136417", "0.63073975", "0.6271965", "0.62241507", "0.61951065", "0.616893...
0.7360268
1
Computation of precision of the Information Retrieval System at a given value of k, averaged over all the queries
def meanPrecision(self, doc_IDs_ordered, query_ids, qrels, k): meanPrecision = -1 #Fill in code here if self.relevances is None: self.relevances = get_relevances(qrels) sum_prec = 0 for i, query_id in enumerate(query_ids): true_doc_IDs = list(self.relevances[query_id].keys()) sum_prec += self.quer...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_precision(self, k=None):\n k = 1 if k is None else k\n precisions = []\n \n for query, answer in tqdm(zip(self.test_queries, self.results)):\n correct_set = self.correct_answers[query]\n n_relevant = 0\n for candidate in answer[:k]:\n ...
[ "0.7700733", "0.7222168", "0.72079796", "0.7187886", "0.71558654", "0.7144129", "0.7119771", "0.7002694", "0.6909865", "0.66777325", "0.6585767", "0.6577343", "0.6562586", "0.6553722", "0.65215147", "0.6517774", "0.65122336", "0.63797057", "0.6371266", "0.6353953", "0.6307624...
0.6836208
9
Creates a convolutional auto encoder that can be used for feature transformation.
def __init__(self, n_latent_features=1024, reduced_size=64, activation=ReLU()): super().__init__() self.logger = logging.getLogger(AutoEncoderConvolutional.__name__) self.n_latent_features = n_latent_features self.reduced_size = reduced_size self.middle_layer_size = int(16 * sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_full_conv_autoencoder():\n input_img = Input(shape=(84, 84, 3))\n\n x = Convolution2D(48, 8, 8, activation='relu', border_mode='same', name='c1')(input_img)\n x = MaxPooling2D((2, 2), border_mode='same')(x)\n x = Convolution2D(32, 4, 4, activation='relu', border_mode='same', name='c2')(x)\n ...
[ "0.7798605", "0.72569174", "0.71783584", "0.6593385", "0.65660286", "0.65586466", "0.653605", "0.65095043", "0.649257", "0.64854586", "0.6466929", "0.6454648", "0.64312893", "0.6414888", "0.64054275", "0.6397273", "0.63966644", "0.6359911", "0.63087416", "0.63070834", "0.6202...
0.0
-1
Returns a trainer type for this model.
def get_trainer(self): return AutoEncoderTrainer
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def trainer(self):\n return self._trainer", "def ethertype(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"ethertype\")", "def return_weightType(self):\n return self.__type", "def target_type(self) -> str:\n return pulumi.get(self, \"target_type\")", "def ethertype(self) -> ...
[ "0.6573329", "0.60546494", "0.6017295", "0.6007788", "0.60014826", "0.6000058", "0.6000058", "0.5999249", "0.599906", "0.5964108", "0.5963045", "0.59616524", "0.59580946", "0.59580946", "0.59580946", "0.59580946", "0.59580946", "0.59580946", "0.59580946", "0.59580946", "0.595...
0.6353113
1
When creating a new object, set the author field.
def save_model(self, request, obj, form, change): if not change: obj.author = request.user obj.save()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform_create(self, serializer):\r\n serializer.save(author=self.request.user)", "def set_author (self, author):\n self.author = author", "def perform_create(self, serializer):\n serializer.save(author=self.request.user)", "def author(self, author):\n self._author = author", ...
[ "0.7711025", "0.7703019", "0.76805794", "0.76462317", "0.76035583", "0.74754244", "0.74754244", "0.73333627", "0.73333627", "0.73333627", "0.7315225", "0.7287557", "0.72669506", "0.7177575", "0.714223", "0.7086051", "0.7020372", "0.7020372", "0.70166945", "0.6964048", "0.6960...
0.7359737
7
Get major device class.
def get_major_device_class(self) -> MajorDeviceClassStr: return MAJOR_DEVICE_CLASS.inverse[self.majorDeviceClass()]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_minor_device_class(self) -> str:\n major = self.get_major_device_class()\n match major:\n case \"computer\":\n flag = mod.MinorComputerClass(self.minorDeviceClass())\n return MINOR_COMPUTER_CLASS.inverse[flag]\n case \"phone\":\n ...
[ "0.81268525", "0.76816213", "0.7636946", "0.7580366", "0.7454239", "0.7454239", "0.7441851", "0.734338", "0.73182285", "0.7201807", "0.7201691", "0.71914905", "0.71914905", "0.71420705", "0.71317774", "0.7084498", "0.70652825", "0.703617", "0.70183957", "0.70183957", "0.70183...
0.8862409
0
Get list of service classes.
def get_service_classes(self) -> list[ServiceClassStr]: return SERVICE_CLASS.get_list(self.serviceClasses())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_services(self):\r\n return get_service_list()", "def get_services(self):\n services = []\n for f in dir(self):\n o = getattr(self, f)\n if callable(o) and hasattr(o, '_service_name'):\n services.append(getattr(o, '_service_name'))\n return ...
[ "0.72681034", "0.7091096", "0.70287013", "0.7020372", "0.7020372", "0.7020372", "0.7020372", "0.7020372", "0.7020372", "0.7020372", "0.7020372", "0.7020372", "0.7020372", "0.7020372", "0.7020372", "0.7020372", "0.7020372", "0.7020372", "0.7006421", "0.69624066", "0.6943913", ...
0.8791884
0
Pad the list of matrices with a pad_value (e.g., 0) for batch processing. For example, given a list of matrices [A, B, C], we obtain a new matrix [A00, 0B0, 00C], where 0 is the zero (i.e., pad value) matrix.
def pad(self, matrices, pad_value): shapes = [m.shape for m in matrices] M, N = sum([s[0] for s in shapes]), sum([s[1] for s in shapes]) zeros = torch.FloatTensor(np.zeros((M, N))).to(device) pad_matrices = pad_value + zeros i, j = 0, 0 for k, matrix in enumerate(matrices...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pad_list(xs: torch.Tensor, pad_value: int):\n n_batch = len(xs)\n max_len = max(x.size(0) for x in xs)\n pad = xs[0].new(n_batch, max_len, *xs[0].size()[1:]).fill_(pad_value)\n\n for i in range(n_batch):\n pad[i, : xs[i].size(0)] = xs[i]\n\n return pad", "def pad_ndarray_list(batch, pad...
[ "0.7486981", "0.7368141", "0.71724635", "0.71428883", "0.713875", "0.6847906", "0.67590123", "0.6669896", "0.65855783", "0.6507169", "0.6431243", "0.63959396", "0.63301456", "0.6327259", "0.6319159", "0.63022196", "0.6290608", "0.62847054", "0.62819785", "0.6264788", "0.62457...
0.848064
0
The InfiniteDurationSourceDict class initialiser.
def __init__(self, values: dict): self.type = InfiniteDurationSource
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, values: dict):\n self.sources = InfiniteDurationSourceDict", "def __init__(self, values: dict):\n\n self.sources = InstantaneousSourceDict", "def __init__(self, values: dict):\n self.instantaneous = InstantaneousSettings\n self.infinite_duration = InfiniteDuration...
[ "0.8324954", "0.6563155", "0.62283415", "0.58405423", "0.58405423", "0.5743138", "0.5611106", "0.5494832", "0.54741186", "0.5428237", "0.5396064", "0.5340886", "0.52986443", "0.5282593", "0.5265673", "0.52640426", "0.5261313", "0.52470773", "0.52071154", "0.51895523", "0.5176...
0.7952653
1