MCPcopy Create free account

hub / github.com/czhang99/Capsule-NLU / functions

Functions58 in github.com/czhang99/Capsule-NLU

↓ 15 callersFunctionis_sequence
Returns a true if its input is a collections.Sequence (except strings). Args: seq: an input sequence. Returns: True if the seque
nest.py:107
↓ 9 callersFunction_yield_value
(iterable)
nest.py:74
↓ 6 callersFunctionflatten
Returns a flat list from a given nested structure. If `nest` is not a sequence, tuple, or dict, then returns a single-element list: `[nest]`.
nest.py:126
↓ 4 callersFunction__endOfChunk
(prevTag, tag, prevTagType, tagType, chunkEnd=False)
utils.py:131
↓ 4 callersFunction__startOfChunk
(prevTag, tag, prevTagType, tagType, chunkStart=False)
utils.py:107
↓ 4 callersFunctionmkMask
(input_tensor, maxLen)
TfUtils.py:8
↓ 3 callersFunction_create_ta
(name, dtype)
TfUtils.py:95
↓ 3 callersFunction_sequence_like
Converts the sequence `args` to the same type as `instance`. Args: instance: an instance of `tuple`, `list`, `namedtuple`, `dict`, or
nest.py:44
↓ 3 callersFunctionassert_shallow_structure
Asserts that `shallow_tree` is a shallow structure of `input_tree`. That is, this function tests if the `input_tree` structure can be created fro
nest.py:420
↓ 3 callersFunctioncreateVocabulary
(input_path, output_path, pad=True, unk=True)
utils.py:27
↓ 3 callersFunctionloadVocabulary
(path)
utils.py:61
↓ 3 callersFunctionsentenceToIds
(data, vocab, unk)
utils.py:76
↓ 2 callersFunction__splitTagType
(tag)
utils.py:155
↓ 2 callersFunction_sorted
Returns a sorted list of the dict keys, with error if keys not sortable.
nest.py:36
↓ 2 callersFunctionbuild_model
(input_data, input_size, sequence_length, slot_size, intent_size, intent_dim, layer_size, embed_dim,
create_model.py:7
↓ 2 callersMethodget_batch
(self, batch_size)
utils.py:277
↓ 2 callersFunctionmasked_routing_iter
Args: caps_uhat: shape(b_sz, tstp, out_caps_num, out_caps_dim) seqLen: shape(b_sz) iter_num: number of iteration
capsule_masked.py:49
↓ 2 callersFunctionpack_sequence_as
Returns a given flattened sequence packed into a given structure. If `structure` is a scalar, `flat_sequence` must be a single-element list;
nest.py:306
↓ 2 callersFunctionpadSentence
(s, max_length, vocab)
utils.py:102
↓ 2 callersFunctionvalid
(in_path, slot_path, intent_path)
train.py:255
↓ 1 callersFunction_leaky_routing
Adds extra dimmension to routing logits. This enables active capsules to be routed to the extra dim if they are not a good fit for any of the
module.py:38
↓ 1 callersFunction_packed_nest_with_indices
Helper function for pack_sequence_as. Args: structure: Substructure (list / tuple / dict) to mimic. flat: Flattened values to output
nest.py:275
↓ 1 callersFunction_recursive_assert_same_structure
Helper function for `assert_same_structure`.
nest.py:157
↓ 1 callersFunction_squash
Squashing function corresponding to Eq. 1 Args: in_caps: a tensor axes: dimensions along which to apply squash Retu
capsule_masked.py:109
↓ 1 callersFunction_squash
Applies norm nonlinearity (squash) to a capsule layer. Args: input_tensor: Input tensor. Shape is [batch, num_channels, num_atoms]
module.py:22
↓ 1 callersFunction_update_routing
Sums over scaled votes and applies squash to compute the activations. Iteratively updates routing logits (scales) based on the similarity between
module.py:57
↓ 1 callersFunction_warn_once
Logs a warning message, once per unique string.
nest.py:101
↓ 1 callersFunction_yield_flat_nest
(nest)
nest.py:88
↓ 1 callersFunction_yield_flat_up_to
Yields elements `input_tree` partially flattened up to `shallow_tree`.
nest.py:409
↓ 1 callersFunctionassert_same_structure
Asserts that two structures are nested in the same way. Args: nest1: an arbitrarily nested structure. nest2: an arbitrarily nested st
nest.py:192
↓ 1 callersFunctioncomputeF1Score
(correct_slots, pred_slots)
utils.py:168
↓ 1 callersFunctionflatten_up_to
Flattens `input_tree` up to `shallow_tree`. Any further depth in structure in `input_tree` is retained as elements in the partially flatten o
nest.py:479
↓ 1 callersFunctionlinear
Linear map: sum_i(args[i] * W[i]), where W[i] is a variable. Args: args: a 2D Tensor or a list of 2D, batch x n, Tensors. output_size
TfUtils.py:160
↓ 1 callersFunctionmargin_loss
Penalizes deviations from margin for each logit. Each wrong logit costs its distance to margin. For negative logits margin is 0.1 and for posi
utils.py:6
↓ 1 callersFunctionshared_routing_uhat
Args: caps: # shape(b_sz, caps_num, caps_dim) out_caps_num: #number of output capsule out_caps_dim: #dimension of output
capsule_masked.py:29
↓ 1 callersMethodshuffle
(self)
utils.py:273
Method__init__
(self, out_caps_num, out_caps_dim, iter_num=3, wrr_dim=(1, 1), reuse=None)
capsule_masked.py:13
Method__init__
(self, in_path, slot_path, intent_path, in_vocab, slot_vocab, intent_vocab, shuffle=False)
utils.py:257
Method__init__
(self, input_dim, input_atoms, output_dim, output_atoms, layer_name)
module.py:120
Function_body
Routing while loop.
module.py:83
Function_softmax_with_mask
Helper function for softmax on variable-length sequences. Args: logits: The logits before softmax. Shape is [batch, type_num, clas
module.py:6
Functionbatch_gather
Gather slices from `params` according to `indices` with leading batch dims. This operation assumes that the leading dimensions of `indices` are de
TfUtils.py:236
Methodcall
(self, in_caps, seqLen, caps_ihat=None, re_routing=False)
capsule_masked.py:20
Methodclose
(self)
utils.py:268
Functionembed_lookup_last_dim
embedding: shape(b_sz, tstp, emb_sz) ids : shape(b_sz, tstp)
TfUtils.py:87
Functionentry_stop_gradients
Args: target: a tensor mask: a boolean tensor that broadcast to the rank of that to target tensor Returns: ret: a ten
TfUtils.py:123
Functionflatten_dict_items
Returns a dictionary with flattened keys and values. This function flattens the keys and values of a dictionary, which can be arbitrarily nes
nest.py:219
Functionget_available_gpus
()
TfUtils.py:227
Functionget_traverse_shallow_structure
Generates a shallow structure from a `traverse_fn` and `structure`. `traverse_fn` must accept any possible subtree of `structure` and return
nest.py:626
Functionlast_dim_linear
Args: input: shape(b_sz, ..., rep_sz) output_size: a scalar, python number
TfUtils.py:141
Functionloop_body
(time, output_ta)
TfUtils.py:106
Functionmap_structure
Applies `func` to each entry in `structure` and returns a new structure. Applies `func(x[0], x[1], ...)` where x[i] is an entry in `structure
nest.py:356
Functionmap_structure_up_to
Applies a function or op to a number of partially flattened inputs. The `inputs` are flattened up to `shallow_tree` before being mapped. Use
nest.py:552
Functionmargin_loss
:param y_true: [None, n_classes] :param y_pred: [None, n_classes] :return: a scalar loss value.
capsule_masked.py:91
Functionmasked_softmax
(inp, seqLen)
TfUtils.py:213
Functionreduce_avg
Args: reduce_target : shape(d_0, d_1,..,d_dim, .., d_k) lengths : shape(d0, .., d_(dim-1)) dim : which dimension to avera
TfUtils.py:17
Functionreduce_sum
Args: reduce_target : shape(d_0, d_1,..,d_dim, .., d_k) lengths : shape(d0, .., d_(dim-1)) dim : which dimension to avera
TfUtils.py:52
Methodvote_and_route
(self, input_tensor, leaky=False)
module.py:132