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
Convert a float value into a pretty printable latex format makes 1.3123e11 transformed into $1.31 x 10 ^ {11}$
def latex_float(f, precision=0.2, delimiter=r'\times'): float_str = ("{0:" + str(precision) + "g}").format(f) if "e" in float_str: base, exponent = float_str.split("e") return (r"{0}" + delimiter + "10^{{{1}}}").format(base, int(exponent)) else: return float_str
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def float_to_latex(x, format=\"%.2g\"):\n base_str = format % x\n if \"e\" not in base_str:\n return base_str\n mantissa, exponent = base_str.split(\"e\")\n if float(mantissa).is_integer():\n mantissa = int(float(mantissa))\n exponent = exponent.lstrip(\"0+\")\n if exponent.startswi...
[ "0.7656031", "0.76299405", "0.72920036", "0.7184618", "0.710542", "0.7067629", "0.70620537", "0.70595986", "0.69403565", "0.66062796", "0.6604243", "0.65625316", "0.65206033", "0.6512583", "0.6500713", "0.6500713", "0.6498947", "0.64924467", "0.64645684", "0.6454142", "0.6440...
0.74447453
2
Return an encoder for a basic varint value (does not include tag).
def _VarintEncoder(): local_int2byte = struct.Struct('>B').pack def EncodeVarint(write, value, unused_deterministic=None): bits = value & 0x7f value >>= 7 while value: write(local_int2byte(0x80|bits)) bits = value & 0x7f value >>= 7 return write(local_int2byte(bits)) return En...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encode(self, value: typing.Union[int, str]) -> int:\n return int(value)", "def encode_varint(value):\n if not isinstance(value, int):\n raise TypeError(\"VarInt encode requires an int type\")\n\n output = bytearray()\n encoder._EncodeSignedVarint(output.extend, value)\n return outpu...
[ "0.6990528", "0.6970189", "0.68203515", "0.67921", "0.67457116", "0.6385981", "0.6379507", "0.6379507", "0.6328247", "0.6327472", "0.6299864", "0.62907934", "0.62672895", "0.6242986", "0.60761327", "0.6061595", "0.6010371", "0.59908605", "0.5889786", "0.5786471", "0.5722378",...
0.73119825
0
Gets Member object of currently logged in user.
def get_current_user(request): user_id = request.session.get('user_id', False) return Member.objects.get(id=user_id)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(user):\n if user:\n return Member.get_by_key_name(user.user_id())", "def get_member(self, *args, **kwargs):\n return self.bot.get_chat_member(self.id, *args, **kwargs)", "def getMember(self):\n pm = getToolByName(self, 'portal_membership', None)\n # stick to the C...
[ "0.7868474", "0.75590235", "0.7512183", "0.745194", "0.740759", "0.72014785", "0.7177086", "0.7176129", "0.7087068", "0.70391643", "0.7039086", "0.7039086", "0.7010212", "0.7010212", "0.7010212", "0.7010212", "0.7010212", "0.69195724", "0.6914278", "0.6889614", "0.6871694", ...
0.75155574
2
Return a dictionary containing only the attributes which map to an instance's database columns.
def as_dict(self, depth=0): result_dict = {} for column in self.__table__.columns.keys(): result_dict[column] = getattr(self, column, None) if isinstance(result_dict[column], Decimal): result_dict[column] = str(result_dict[column]) result_dict['links'] = s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def attributes(self):\n return { k: getattr(self, k) for k in self.__class__.columns().keys() }", "def as_dict(self):\n return {c.key: getattr(self, c.key)\n for c in inspect(self).mapper.column_attrs}", "def to_dict(self):\n columns = self.__mapper__.column_attrs.keys()\n ...
[ "0.8177488", "0.78735983", "0.75453395", "0.75453395", "0.75453395", "0.75453395", "0.75453395", "0.7469915", "0.7469915", "0.7469915", "0.7469915", "0.740771", "0.7374471", "0.7346471", "0.73197234", "0.7265089", "0.7245162", "0.7134042", "0.71290135", "0.69970226", "0.69890...
0.0
-1
Returns HTML from MediaWiki markup ignoring without headings
def parselite(text): p = BaseParser() return p.parse(text)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def non_thesis():\n spider = phenix_spider.PhenixSpider()\n body = \"\"\"\n <ul>\n <li><b>M.Sc. Author</b>:\n \"This is an Master's thesis, not a PhD\", &nbsp; M.Sc. thesis at Master Science University, 2016,&nbsp;\n <br><br>\n </ul>\n \"\"\"\n response = fake_response_from_string(body)\...
[ "0.6572633", "0.6423304", "0.6235957", "0.6214049", "0.61630607", "0.5924587", "0.5869513", "0.58508813", "0.5832656", "0.5821629", "0.57504433", "0.5747117", "0.5736978", "0.5736978", "0.5717043", "0.56911623", "0.5687446", "0.5661609", "0.5661236", "0.56564367", "0.56442976...
0.0
-1
Returns the ROI's average. If recalc = True, will recalculate the value before returning it.
def get_ave(self, recalc=False): if self.ave is not None and not recalc: return self.ave self.ave = np.mean(self.img.ravel()) return self.ave
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def average_rating(self):\n ratings = Rating.objects.filter(game=self)\n\n if len(ratings):\n # Sum all of the ratings for the game\n total_rating = 0\n for rating in ratings:\n total_rating += rating.value\n\n # Calculate the averge and retu...
[ "0.61489785", "0.61467844", "0.5948553", "0.59483784", "0.59483784", "0.59079343", "0.5871713", "0.58700836", "0.58606017", "0.5842122", "0.58277714", "0.58212984", "0.5793691", "0.5789793", "0.5779534", "0.57645524", "0.5752506", "0.5731902", "0.57195044", "0.5705744", "0.56...
0.7093712
0
Returns an instance of Result with a copy of the context state.
def result(self): return Result(self.messages[:])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def copy(self):\n return Result(super().copy())", "def copy(self):\n rv = Context(self.decimal, self.year_mode, self.quantize_interest,\n self.quantize_currency)\n return rv", "def copy(self) -> \"RequestContext\":\n return super().copy()", "def test_context_im...
[ "0.76974994", "0.6946769", "0.6735816", "0.63316166", "0.6188996", "0.6089899", "0.607145", "0.606768", "0.6024504", "0.5966603", "0.59072953", "0.5902032", "0.59011436", "0.5886955", "0.58713424", "0.586794", "0.58679223", "0.58124757", "0.5812147", "0.5802163", "0.5796928",...
0.0
-1
Returns True if the user has only dropped degrees from first, and False if there have been either no degrees dropped or one added.
def _has_only_dropped_degrees(first, second): has_dropped = len(set(first) - set(second)) > 0 has_added = len(set(second) - set(first)) > 0 return (has_dropped and not has_added)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_droppable ( self, object, row, value ):\n return self.droppable", "def should_drop(self):\n # type: () -> bool\n if self._drop_if_none and self.value is None:\n return True\n if self._drop_if_default and self.value == self._default:\n return True\n return False", "def oneupp...
[ "0.5857444", "0.5666408", "0.5666203", "0.56371725", "0.5563048", "0.55080914", "0.5458156", "0.5443643", "0.5370935", "0.53071386", "0.5260153", "0.5243031", "0.5218293", "0.516429", "0.51229906", "0.5103722", "0.5081523", "0.50793934", "0.50673395", "0.5008508", "0.49991286...
0.6965596
0
Returns the number of stops done at the node.
def counter_callback(from_index): from_node = manager.IndexToNode(from_index) return data['counter'][from_node]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count(self):\n\t\treturn len(list(self.nodes))", "def count_nodes(self):\n\t\treturn self.__count_nodes(self)", "def node_count(self) -> pulumi.Output[int]:\n return pulumi.get(self, \"node_count\")", "def node_count(self) -> pulumi.Output[int]:\n return pulumi.get(self, \"node_count\")", ...
[ "0.6199437", "0.6170811", "0.6135748", "0.6135748", "0.61114854", "0.6095156", "0.607958", "0.60653067", "0.6059429", "0.60576844", "0.6029593", "0.6013222", "0.59944504", "0.5985826", "0.5971928", "0.5971753", "0.59659606", "0.5958388", "0.59286577", "0.59286577", "0.5896272...
0.0
-1
Closes the output stream and the underlying file handle.
def close(self): self.file.close() self.file = None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close(self):\n self.outfd.close()", "def close(self):\n self.file_out.close()", "def close(self):\n self.out_file.close()", "def close(self):\n self.output.close()", "def close_file_handle(self):\n if self.file_handle and self.output_file:\n self.file_handl...
[ "0.78165716", "0.7792495", "0.77480096", "0.7702004", "0.76847625", "0.76437896", "0.74435663", "0.7345508", "0.72881055", "0.71692944", "0.71483976", "0.7087295", "0.70621675", "0.7022005", "0.70041776", "0.7003337", "0.7000088", "0.69676226", "0.69659656", "0.69347256", "0....
0.6568598
53
Implements the sigmoid activation.
def sigmoid(Z): A = 1.0/(1.0+np.exp(-Z)) cache = Z return A, cache
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def activation_sigmoid(self):\n self.value = 1 / (1 + np.e ** (-self.value))", "def sigmoid(X,W,b):\n preActivation = np.dot(X, W) + b\n return (1.0)/(1.0 + np.exp(-preActivation))", "def sigmoid_activation(x):\n return 1.0 / (1 + np.exp(-x))", "def activation_sigmoid_custom(self):\n s...
[ "0.84636855", "0.8395285", "0.83947587", "0.8323654", "0.82396793", "0.82216316", "0.82216316", "0.81867284", "0.81373173", "0.81194216", "0.811582", "0.80981916", "0.809196", "0.80870104", "0.8084226", "0.80674106", "0.8064058", "0.8064058", "0.8064058", "0.8064058", "0.8064...
0.0
-1
Implement the backward propagation for a single RELU unit
def relu_backward(dA, cache): Z = cache dZ = np.array(dA, copy=True) dZ[Z <= 0] = 0 return dZ
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def backward(ctx, grad_output):\n loss, reg, u, lbda = ctx.saved_tensors\n\n device = u.device\n\n # do clever computations\n eps = 1e-10\n grad, = torch.autograd.grad(loss, u, only_inputs=True,\n retain_graph=True)\n x = (u - eps * grad)...
[ "0.73298776", "0.72214615", "0.7158809", "0.7103985", "0.7101634", "0.70909655", "0.7090952", "0.7072687", "0.70668036", "0.7035713", "0.6991938", "0.69911265", "0.6973394", "0.6973394", "0.6940245", "0.6922302", "0.6911255", "0.6901201", "0.68641424", "0.68608546", "0.686085...
0.0
-1
Initializes v and s for Adam optimizer
def initialize_adam(parameters) : L = len(parameters) // 2 v = {} s = {} for l in range(L): v["dW" + str(l + 1)] = np.zeros_like(parameters["W" + str(l + 1)]) v["db" + str(l + 1)] = np.zeros_like(parameters["b" + str(l + 1)]) s["dW" + str(l+1)] = np.zeros_like(parameters["W" + ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize(self): \n self.optimizer = torch.optim.Adam(self.model.parameters(), lr=config.LR)", "def initialize_optimization(self):\n\n if self.FLAGS.optimizer == \"Adam\" :\n self.solver = tf.train.AdamOptimizer(\n learning_rate = self.learning_rate,\n ...
[ "0.71869504", "0.67375606", "0.6541036", "0.648194", "0.6478172", "0.64585817", "0.6451515", "0.644802", "0.6404837", "0.63996816", "0.63829875", "0.63461226", "0.6345778", "0.6277067", "0.6239776", "0.6195247", "0.618676", "0.6177543", "0.6172906", "0.61704576", "0.6144318",...
0.5793667
89
Randomise. In the Deck Inducement phase, open an additional Inducement Skill Pack. Each Training Card in the pack must be applied to a random player on your team. This card is removed from your collection after use.
async def CoM2000(self, ctx): me = CoachService.discord_user_to_coach(ctx.author) data = getattr(special_play, inspect.currentframe().f_code.co_name)(ctx.channel.name, me) await self.send_embed(data, ctx)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def deal(self):\n deck = range(3, 36)\n self.cards = sample(deck, 24)\n self.card = self.cards.pop()", "def setup_newgame(self):\n global chips\n self.bet = 100\n if chips < self.bet: \n self.game_over = True\n chips -= self.bet\n \n\n sel...
[ "0.6395528", "0.63410896", "0.6281078", "0.6242871", "0.59800154", "0.5962487", "0.594015", "0.58646303", "0.5842997", "0.5828354", "0.5773102", "0.5769582", "0.57493097", "0.57368654", "0.5722945", "0.5719397", "0.57075644", "0.56969506", "0.5689548", "0.5687842", "0.5679114...
0.0
-1
Randomise. In the Deck Inducement phase, open one additional Inducement Skill Pack and one additional Inducement Coaching Pack. Each Training Card in the pack must be applied to a random player on your team. This card is removed from your collection after use.
async def CoM5000(self, ctx): me = CoachService.discord_user_to_coach(ctx.author) data = getattr(special_play, inspect.currentframe().f_code.co_name)(ctx.channel.name, me) await self.send_embed(data, ctx)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_newgame(self):\n global chips\n self.bet = 100\n if chips < self.bet: \n self.game_over = True\n chips -= self.bet\n \n\n self.cards_list = arcade.SpriteList()\n\n #resets on newgame\n self.top_card_int = 0 ## this had to be moved here to...
[ "0.65399456", "0.6415693", "0.6274851", "0.6042319", "0.60149777", "0.5946432", "0.5933154", "0.58695483", "0.58560777", "0.58431846", "0.5829015", "0.5819242", "0.58177656", "0.5804596", "0.5803811", "0.578058", "0.5779705", "0.5765569", "0.5733727", "0.57179946", "0.5684146...
0.0
-1
Randomise. Choose one Special Play card that is yet to be resolved. The chosen card must now be played as if it had the Randomise key word. In the Deck Inducement phase, open three additional Inducement Coaching Packs. Each Training Card in the pack must be applied to a random player on your team. This card is removed ...
async def CoM9000(self, ctx): me = CoachService.discord_user_to_coach(ctx.author) data = getattr(special_play, inspect.currentframe().f_code.co_name)(ctx.channel.name, me) await self.send_embed(data, ctx)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def choose_card_to_discard(self):\n random.choice(self.hand.card_list).use()", "def deal_cards(self):\n self.card = random.randint(1, 13)\n return self.card", "def deal_one(self):\r\n rand_card = random.choice(self.cards_list)\r\n self.cards_list.remove(rand_card)\r\n ...
[ "0.683222", "0.673332", "0.6671004", "0.6658041", "0.6606564", "0.6566545", "0.6537025", "0.65340483", "0.6495553", "0.64628816", "0.642775", "0.6403685", "0.6381348", "0.63718253", "0.6306838", "0.6297953", "0.62502354", "0.6230062", "0.61853683", "0.6174712", "0.61720616", ...
0.0
-1
Crossentropy loss function, naive implementation (with loops) Inputs have dimension D, there are C classes, and we operate on minibatches of N examples.
def cross_entropoy_loss_naive(W, X, y, reg): # pylint: disable=too-many-locals # Initialize the loss and gradient to zero. loss = 0.0 dW = np.zeros_like(W) C = W.shape[1] # print("no. of classes {}".format(C)) N,D = X.shape # print("no. of data {} and dimension {}".format(N,D)) f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cross_entropy(\n **kwargs\n) -> Callable:\n return categorical_crossentropy", "def cross_entropy(X, y, using_onehot=True):\n\tM = y.shape[0]\n\tif using_onehot :\n\t\tlog_likelihood = -np.log(np.max(X * y, -1))\n\telse:\n\t\tlog_likelihood = -np.log(X[range(M), y]) # 找到y对应的那个类别所对应的logit\n\tloss = n...
[ "0.69493353", "0.69196", "0.6843186", "0.68166006", "0.67589766", "0.670402", "0.66435903", "0.6597671", "0.6579546", "0.65658116", "0.65657854", "0.654136", "0.6520192", "0.6520192", "0.65033543", "0.6501151", "0.64958155", "0.6490431", "0.6481994", "0.6468644", "0.6461069",...
0.6158583
56
Crossentropy loss function, vectorized version. Inputs and outputs are the same as in cross_entropoy_loss_naive.
def cross_entropoy_loss_vectorized(W, X, y, reg): loss = 0 dW = np.zeros_like(W) N, D = X.shape scores = X.dot(W) # [K, N] # for numerical stability) scores -= np.max(scores) scores_exp = np.exp(scores) correct_scores_exp = scores_exp[range(N),y] scores_exp_sum = np....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cross_entropy_loss():\n return nn.CrossEntropyLoss()", "def cross_entropy(y_prob,y):\n from numpy import log, sum\n m = y.shape[0]\n p = y_prob\n log_likelihood = -log(p[range(m),y])\n loss = sum(log_likelihood) / m\n return loss", "def cross_entropy(true, pred, axis=-1, epsilon=1e-7):...
[ "0.7351285", "0.7307446", "0.727371", "0.725751", "0.72501165", "0.72490084", "0.7247223", "0.720159", "0.71913004", "0.7175612", "0.71052086", "0.7095461", "0.70713085", "0.7059449", "0.7036136", "0.70338666", "0.7033684", "0.70231044", "0.70208305", "0.69910353", "0.6929", ...
0.71922183
8
Toggle mute state on the given device path.
def _mute_toggle(self, device_path): device = self.pulse_bus.get_object("org.PulseAudio.Core1.Device", device_path) old_mute = bool(device.Get("org.PulseAudio.Core1.Device", "Mute")) device.Set("org.PulseAudio.Core1.Device", "Mute", dbus.Boolean(not old...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mute():\n request_command(tv_command=TVCommand.mute)", "def mute(self, value: bool) -> None:\n self.audio_mixer.setmute(value)\n self.update_status()", "def toggle_mute(cls) -> bool:\n raise NotImplementedError", "async def async_set_muted(self, mute):\n self._muted = mute"...
[ "0.7088862", "0.70268536", "0.6648116", "0.6647377", "0.6604256", "0.66010445", "0.6522189", "0.6449185", "0.63945925", "0.6376488", "0.63471675", "0.63427687", "0.63285184", "0.6322804", "0.630157", "0.62925977", "0.6288574", "0.62856114", "0.62830997", "0.6282512", "0.62748...
0.84533834
0
Toggle mute state on the the current default output sink.
def mute_output_toggle(self): self._mute_toggle(self.pulse_core.Get("org.PulseAudio.Core1", "FallbackSink"))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mute_input_toggle(self):\n self._mute_toggle(self.pulse_core.Get(\"org.PulseAudio.Core1\", \"FallbackSource\"))", "def speaker_toggle(self, emission, signal, source):\n self.storage.call.mute_toggle()", "def mute():\n request_command(tv_command=TVCommand.mute)", "def mute(self) -> None:\...
[ "0.73350376", "0.69892097", "0.6937658", "0.6934735", "0.6735216", "0.6679772", "0.6660727", "0.66372937", "0.6486977", "0.64717716", "0.6412236", "0.6402196", "0.6384608", "0.637936", "0.6329149", "0.632018", "0.63116795", "0.62267", "0.6181535", "0.6158725", "0.6093601", ...
0.83425736
0
Toggle mute state on the the current default input source.
def mute_input_toggle(self): self._mute_toggle(self.pulse_core.Get("org.PulseAudio.Core1", "FallbackSource"))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mute():\n request_command(tv_command=TVCommand.mute)", "def mute_output_toggle(self):\n self._mute_toggle(self.pulse_core.Get(\"org.PulseAudio.Core1\", \"FallbackSink\"))", "def speaker_toggle(self, emission, signal, source):\n self.storage.call.mute_toggle()", "def mute(self) -> None:\n...
[ "0.7113684", "0.70182806", "0.6976991", "0.6896899", "0.67835814", "0.6740322", "0.6712553", "0.65105945", "0.64521956", "0.6413083", "0.6398017", "0.6397626", "0.6384592", "0.6297712", "0.62880856", "0.6236472", "0.62323886", "0.62102616", "0.61946505", "0.6097208", "0.59286...
0.8215465
0
Returns a ConfigView of config options that match the specified namespace/prefix.
def get_namespace_view(self, namespace, lowercase=True, trim_namespace=True): return ConfigView( self, namespace_key_func( namespace, lowercase=lowercase, trim_namespace=trim_namespace ) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def namespace(self, namespace, lowercase=True, trim_namespace=True):\n\t\treturn Config(\n\t\t\t\tself.root_path,\n\t\t\t\tself.get_namespace_view(namespace, lowercase, trim_namespace)\n\t\t\t)", "def define_options(self):\n return {\n 'basename': OptionDef(required=True, default_value='keycloa...
[ "0.55692685", "0.5057444", "0.50034976", "0.4904862", "0.48599297", "0.48180565", "0.48061582", "0.47581518", "0.47156736", "0.47061652", "0.4690248", "0.4663073", "0.46199337", "0.4616908", "0.45923918", "0.4579549", "0.45745733", "0.45641443", "0.4557248", "0.45321435", "0....
0.6401481
0
Get the registry record.
def get_module(self, cls_name, module_name='module'): if module_name not in self._module_dict: raise KeyError('{module_name} is not in registry') dd = self._module_dict[module_name] if cls_name not in dd: raise KeyError('{cls_name} is not registered in {module_name}') ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getrecord(self, index):\n return RegistryResource(self, index)", "def record(self):\r\n return self._record", "def registry(self):\n return self._registry", "def get_register_record(self, dt = None):\n\t\tdt = dt or datetime.now()\n\t\treturn self.poregister_set.filter(date__lte = dt...
[ "0.77672005", "0.64281845", "0.64039934", "0.6306175", "0.6293095", "0.6226713", "0.62076247", "0.6196547", "0.6162104", "0.61354554", "0.61344516", "0.6069409", "0.6037471", "0.6011908", "0.6008214", "0.5989316", "0.5979534", "0.5977106", "0.59483653", "0.5945065", "0.593989...
0.0
-1
Returns the description passed to the constructor, or a default description if no description was passed to the constructor.
def __str__(self): if self.__description: return self.__description return repr(self)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Description(self, default=None):\n return self.data.get('description', default)", "def Description(self, default=None):\n return self.data.get('description', default)", "def description(self) -> Optional[str]:\n if hasattr(self, \"_description\"):\n return self._desc...
[ "0.77348256", "0.77348256", "0.752265", "0.752265", "0.752265", "0.7449401", "0.7401098", "0.73554754", "0.7343841", "0.73413056", "0.7331982", "0.7331982", "0.7331982", "0.7331982", "0.7331982", "0.7331982", "0.7331982", "0.7331982", "0.7331982", "0.7331982", "0.7331982", ...
0.0
-1
Initialise name and age attributes.
def __init__(self, name, cuisine): self.name = name self.cuisine = cuisine
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, name, age):\n\t\tself.name = name\n\t\tself.age = age", "def __init__(self, name, age):\n\t\tself.name = name\n\t\tself.age = age", "def __init__(self, name, age):\n\t\tself.name = name\n\t\tself.age = age", "def __init__(self, first_name, last_name, age):\n\n self.first_name = firs...
[ "0.76970434", "0.76970434", "0.76970434", "0.76306546", "0.7601589", "0.7601589", "0.7601589", "0.7601589", "0.7601589", "0.7601589", "0.7601589", "0.7601589", "0.74841875", "0.74841875", "0.74841875", "0.74841875", "0.7480149", "0.73749363", "0.72653306", "0.7245375", "0.715...
0.0
-1
Return the cumulative density function of a set of data xs
def cum_density_func(xs,norm=True,rank=False,data_range='data',pdf=None): if pdf is None: pdf = prob_density_func(xs,False,data_range) pdfk = sorted(pdf.keys()) pdfv = map(pdf.get,pdfk) if not rank: cdfv = np.cumsum(pdfv) if norm: cdfv = cdfv/np.sum(pdfv) else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cdf(self,x):\n if hasattr(x,'__len__'):\n returnCdf = np.array([self.cdf(i) for i in x])\n else:\n returnCdf = self._distribution.cdf(x)\n return returnCdf", "def comp_cum_distribution(xs,norm=True,rank=False,data_range='data',pdf=None):\n cdf = cum_density_func(xs,norm,rank,data_range,...
[ "0.7163723", "0.7037059", "0.68452346", "0.6766068", "0.67568934", "0.6709647", "0.6707592", "0.6665174", "0.6665174", "0.661652", "0.660517", "0.659591", "0.65924096", "0.6560842", "0.6458608", "0.6435436", "0.6419457", "0.64163345", "0.6410546", "0.6409281", "0.62895733", ...
0.77029145
0
Return the complement cumulative distribution(CCD) of a list dist Returns the CCD given by P(X>x) = 1 P(X<=x) where P(X<=x) is the cumulative distribution func given by P(X <= x) = sum_{xi<x} p(xi) where p(xi) is the probaility density function calculated as p(xi) = xi/(sum_i xi)
def comp_cum_distribution(xs,norm=True,rank=False,data_range='data',pdf=None): cdf = cum_density_func(xs,norm,rank,data_range,pdf) max_v = np.max(cdf.values()) return dict([(k,max_v - cdf[k]) for k in cdf.keys()])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_cdf(dist):\n cdf = []\n total = 0\n for i in range(len(dist)):\n total += dist[i]\n cdf.append(total)\n return cdf", "def cumulative_distribution(self, dist='current'):\n \n dictDist = {'current': np.cumsum(self.current),\n 'prior': np.cumsum(sel...
[ "0.74975204", "0.6461271", "0.6302453", "0.6296993", "0.6224491", "0.61864716", "0.61723876", "0.6164214", "0.61121863", "0.61091065", "0.6023649", "0.6023649", "0.6022855", "0.5947804", "0.59427214", "0.59368634", "0.5930679", "0.5919316", "0.59102935", "0.5866186", "0.58171...
0.631378
2
This function is used to load image and then resizes to shape(224,224).
def load_face_image(file_name): img = cv2.imread(file_name) img = img.astype('float32') img = cv2.resize(img,(224,224)) return img
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_image(path):\n img = skimage.io.imread(path)\n img = img / 255.0\n assert (0 <= img).all() and (img <= 1.0).all()\n short_edge = min(img.shape[:2])\n yy = int((img.shape[0] - short_edge) / 2)\n xx = int((img.shape[1] - short_edge) / 2)\n crop_img = img[yy: yy + short_edge, xx: xx + sh...
[ "0.7156366", "0.70263433", "0.70119846", "0.68100053", "0.67693573", "0.67574", "0.6718889", "0.67120403", "0.6705569", "0.6682572", "0.6596518", "0.6533306", "0.6528817", "0.6491348", "0.6480874", "0.64632165", "0.64596194", "0.6442846", "0.6427298", "0.642357", "0.64195174"...
0.62318134
31
Parse a single iCalendarformatted line into a ContentLine
def parse(cls, line): if "\n" in line or "\r" in line: raise ValueError("ContentLine can only contain escaped newlines") try: ast = GRAMMAR.parse(line) except FailedToken: raise ParseError() else: return cls.interpret_ast(ast)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_line(self, line):\n raise NotImplementedError", "def parse(cls, line):\r\n raise NotImplementedError", "def __init__(self, line):\n # Throw an exception if we don't see the parenthesis that mark a date entry\n if not line[108] == '(':\n raise ParsingException\n ...
[ "0.67204976", "0.63444155", "0.624129", "0.5989611", "0.5988161", "0.59396523", "0.5882118", "0.5873801", "0.58489716", "0.5830853", "0.5816042", "0.5800984", "0.5748073", "0.5704845", "0.56992835", "0.56992835", "0.56992835", "0.56992835", "0.56956124", "0.5669981", "0.56615...
0.5946531
5
Shooting off a charged shot.
def shoot_blaster(ai, var, screen, ship, blasters): boom = Blast(ai, var, screen, ship) blasters.add(boom)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def shoot(self):\n return self.bot_client.send_command(_Command.Shoot)", "def shoot(self):\n if self.gun_interface:\n self.gun_interface.prepare_fire()", "def shoot(self):\n shots = Shooting(self.rect.centerx, self.rect.bottom)\n # Adding the shots to sprite lists created...
[ "0.7274136", "0.7258856", "0.70343256", "0.7023029", "0.6968963", "0.6961889", "0.68982327", "0.6878659", "0.6739711", "0.6728818", "0.66885394", "0.6603395", "0.6586401", "0.6497653", "0.64521974", "0.6415574", "0.6413016", "0.64071697", "0.6405578", "0.6397033", "0.6377639"...
0.0
-1
Checks for player bullet collisions on enemies.
def ship_bullet_hits(ai, var, screen, ship, enemies, shots, blasters, shockers, items, hub): for shot in shots.copy(): if pygame.sprite.spritecollideany(shot, enemies): for enemy in enemies.copy(): if pygame.sprite.spritecollideany(enemy, shots): enemy.hits += 1 if enemy.hits >= enemy.hp: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_players_collision(self):\n # Check if bullet hit the player 1\n bullet_hit_p = len(pygame.sprite.spritecollide(self.player1, self.player2_bullet, True))\n bullet_hit_m = len(pygame.sprite.spritecollide(self.player1, self.mob_bullet, True))\n if bullet_hit_p and not self.player...
[ "0.78489834", "0.7550087", "0.7534982", "0.7456769", "0.7398647", "0.739656", "0.737982", "0.7371182", "0.73649585", "0.7213203", "0.7193018", "0.7190431", "0.7118374", "0.70968777", "0.6975945", "0.6975213", "0.69614947", "0.68876946", "0.6886869", "0.68702185", "0.68490165"...
0.0
-1
Checks for enemy bullet collisions on player.
def enemy_bullet_hits(ai, screen, ship, enemies, slayers, lasers, shields, hub): if ship.shield: pygame.sprite.groupcollide(slayers, shields, True, False) for slay in slayers.copy(): if pygame.sprite.collide_rect(ship, slay): if not hub.death: hub.h_bar = hub.h_bar - slay.damage #ship.damage()...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_players_collision(self):\n # Check if bullet hit the player 1\n bullet_hit_p = len(pygame.sprite.spritecollide(self.player1, self.player2_bullet, True))\n bullet_hit_m = len(pygame.sprite.spritecollide(self.player1, self.mob_bullet, True))\n if bullet_hit_p and not self.player...
[ "0.76141125", "0.73522645", "0.7294932", "0.7278487", "0.7275845", "0.7254989", "0.7244368", "0.72298723", "0.7220704", "0.72019404", "0.71303827", "0.7112835", "0.7101682", "0.70557535", "0.7050626", "0.6925918", "0.6917084", "0.69056505", "0.68706346", "0.6868787", "0.68043...
0.6179516
46
_tearDown_ Tear down everything and go home.
def tearDown(self): self.testInit.clearDatabase() self.testInit.delWorkDir() EmulatorSetup.deleteConfig(self.configFile) return
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tearDown(self):\n self.m.shutdown()", "def tearDown(self):\n print('Calling \\'tearDown\\'')", "def tearDown(self):\n\n self._tear_down()", "def tearDown(self):\n logging.debug('tearing down')", "def tearDown(self):\n logging.debug('tearing down')", "def tearDown(se...
[ "0.8307112", "0.83026314", "0.82925975", "0.82894653", "0.82894653", "0.8183992", "0.8178049", "0.8146832", "0.8109506", "0.8109506", "0.8109506", "0.8077872", "0.8074141", "0.8074141", "0.8074141", "0.8074141", "0.8069283", "0.8069283", "0.8069283", "0.8069283", "0.80594665"...
0.0
-1
View that returns the home page.
def index(request): return render(request, 'vaxcharts/home.html')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def home():\n\n return render_template('home_page.html')", "def home():\n\n\treturn render_template('index.html', title='Home Page',\n\t\t\t\t\t\t year=datetime.now().year)", "def home(request):\n\treturn render(request, \"compta/home.html\")", "def home(request):\n return render_to_response('home.ht...
[ "0.8407515", "0.835119", "0.83096266", "0.83003306", "0.8291927", "0.82916033", "0.82615095", "0.82250273", "0.82250273", "0.82250273", "0.82250273", "0.82250273", "0.82250273", "0.82250273", "0.82250273", "0.82250273", "0.82250273", "0.8212028", "0.8207739", "0.8203969", "0....
0.0
-1
Create train test split from the incoming data frame. During training this will create both sets, during production we only need test
def create_train_test(dataframe_all): label_encoder=LabelEncoder() split = StratifiedShuffleSplit(n_splits=1, test_size=0.1, random_state=42) for train_index, test_index in split.split(dataframe_all['word_values'], dataframe_all['document_label']): strat_train_set = dataframe_all.loc[train_index] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def train_test_split(df, test_size=0.3):\r\n # split df here\r\n train_size = int(df.shape[0] * (1 - test_size))\r\n test_size = df.shape[0] - train_size\r\n train = df[:train_size]\r\n test = df[train_size:]\r\n\r\n return train, test # return the train and test datasets\r", "def split_test_t...
[ "0.8001278", "0.7887381", "0.7859322", "0.76992023", "0.76608014", "0.7646634", "0.75352776", "0.7488362", "0.7451589", "0.74227184", "0.7405074", "0.7391072", "0.7369148", "0.73666316", "0.7356318", "0.7347281", "0.7344243", "0.7341544", "0.7314268", "0.725524", "0.7252032",...
0.70733947
34
Display home page Fetch all categories and latest items.
def home(): categories = session.query(Category).all() latest_items = session.query(Item).order_by( Item.created_date.desc()).limit(ITEM_COUNT).all() return render_template( 'views/catalog.html', categories=categories, latest_items=latest_items, user_in_session=user_i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_homepage():\n max_items = 5\n all_categories = session.execute(\n 'SELECT category.name, category.id, count(item.id) AS item_count '\n 'FROM category '\n 'LEFT JOIN item ON category.id = item.category_id '\n 'GROUP BY category.name, category.id')\n items = session.quer...
[ "0.8014896", "0.7208272", "0.7186291", "0.6817325", "0.676333", "0.6751716", "0.6667638", "0.6660886", "0.6586851", "0.6558749", "0.6552555", "0.6490337", "0.64261276", "0.6395155", "0.6357209", "0.63022673", "0.62654674", "0.62272954", "0.62022454", "0.61571026", "0.6140312"...
0.77747077
1
Get JSON for all categories and items in database
def catalog_json(): catalog_json = [] try: all_categories = session.query(Category).all() for category in all_categories: items_for_category = session.query( Item).filter_by( category_id=category.id).all() items = [] for cur...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def catelogJSON():\n categories = session.query(Category).all()\n items = session.query(Item).all()\n catelog = []\n for i in categories:\n li = []\n for j in items:\n if j.category_id == i.id:\n temp = j.serialize\n li += [temp]\n temp = i....
[ "0.8282663", "0.79611033", "0.7912406", "0.7811919", "0.7797428", "0.7782607", "0.76939803", "0.76844555", "0.7657332", "0.7656953", "0.7629297", "0.7605853", "0.74813694", "0.74558586", "0.74385047", "0.7425071", "0.7408617", "0.73705274", "0.73622185", "0.7360726", "0.72572...
0.77163136
6
Adds a condition entry to the patients data struct
def add_condition(self, condition_concept_id, condition_start_date, condition_start_datetime, condition_type_concept_id, **kwargs): # add all optional values condition_d = {key: value for key, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_condition(self):\n m = self.get_current_measurement()\n result = PriorityDialog()\n if result.exec_():\n # Update Survey.priority based on the input\n key, val1, val2, weight = result.key, result.val1, result.val2, result.weight\n \n # If the...
[ "0.6369687", "0.6168765", "0.614632", "0.61157244", "0.59635335", "0.5887625", "0.57270205", "0.5630401", "0.56180614", "0.55696917", "0.55176055", "0.55122477", "0.5497737", "0.53868634", "0.5367074", "0.5361532", "0.5348016", "0.53102183", "0.5270889", "0.5253811", "0.52176...
0.6362052
1
Create a onehotencoded version of a categorical feature and append it to the existing dataframe. After onehot encoding the categorical feature, ensure that the original categorical feature is dropped from the dataframe so that only the onehotencoded features are retained.
def addDummyFeatures(inputDf, feature): ## TODO ## if feature not in inputDf.columns: return('Feature not in dataset') rows,columns = inputDf.shape feature_List = [] OHE_Matrix = np.array([[]]) #Create a matrix to store the OHE values for i in range(rows): if pd.isna(inputDf.lo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _one_hot_encoder(self):\n ohe = preprocessing.OneHotEncoder()\n ohe.fit(self.dataframe[self.cat_feats])\n return ohe.transform(self.dataframe_d_copy[self.cat_feats])", "def one_hot(df):\r\n # One-hot encode into \r\n cols = ['job', 'marital', 'education', 'month', 'day_of_week', 'p...
[ "0.7832615", "0.77566874", "0.77540827", "0.75883305", "0.7577786", "0.7478292", "0.7450068", "0.7421077", "0.73564774", "0.7344144", "0.73146987", "0.731349", "0.7285724", "0.7237436", "0.7187014", "0.7185547", "0.7143728", "0.7139684", "0.7051456", "0.7023153", "0.70186293"...
0.0
-1
Create a onehotencoded version of a categorical feature and append it to the existing dataframe. After onehot encoding the categorical feature, ensure that the original categorical feature is dropped from the dataframe so that only the onehotencoded features are retained.
def addDummyFeatures(inputDf, feature): ## TODO ## if feature not in inputDf.columns: return('Feature not in dataset') rows,columns = inputDf.shape feature_List = [] OHE_Matrix = np.array([[]]) #Create a matrix to store the OHE values for i in range(rows): if pd.isna(inputDf.lo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _one_hot_encoder(self):\n ohe = preprocessing.OneHotEncoder()\n ohe.fit(self.dataframe[self.cat_feats])\n return ohe.transform(self.dataframe_d_copy[self.cat_feats])", "def one_hot(df):\r\n # One-hot encode into \r\n cols = ['job', 'marital', 'education', 'month', 'day_of_week', 'p...
[ "0.78325605", "0.7755536", "0.77537924", "0.75882536", "0.75790447", "0.7477965", "0.74497914", "0.74209625", "0.7355706", "0.73437995", "0.7313817", "0.73126787", "0.72850335", "0.72364175", "0.7186117", "0.71846265", "0.7144258", "0.71396786", "0.70504445", "0.7021892", "0....
0.0
-1
Return a friendly HTTP greeting.
def hello(): return 'Hello I like to make AI Apps'
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_greeting(name):\n\n greeting = (f\"Hello, {name.title()}. It's nice to meet you!\")\n return greeting", "def welcome():\n return 'Welcome to Flask!'", "def greeting_message(name):\n print('My name is ' + name)", "def Welcome():\n return (\n f\"Welcome to the Surf's Up API!\...
[ "0.67860854", "0.6719625", "0.67095745", "0.6680697", "0.6663219", "0.6638394", "0.6633062", "0.6628187", "0.6556032", "0.6536937", "0.64776874", "0.6477268", "0.64715713", "0.64644194", "0.6443056", "0.6435385", "0.6400719", "0.6400167", "0.637615", "0.637615", "0.6367243", ...
0.6337529
24
Removes stop words from text.
def remove_stop_words(self, content): stop_words = set(stopwords.words('english')) words = nltk.word_tokenize(content) words = [word.lower() for word in words if word.isalpha()] return [w for w in words if not w in stop_words]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_stopwords(self,text):\n return \" \".join([word for word in str(text).split() if word not in self.STOPWORDS])", "def remove_stopwords(text):\n text = \" \"+text\n text = text.upper()\n for word in STOP_WORDS:\n text = text.replace(word.upper(),\" \")\n return text", "def re...
[ "0.8792427", "0.8763001", "0.8717276", "0.85046715", "0.8483983", "0.843941", "0.842972", "0.84121877", "0.8358379", "0.8356522", "0.82617944", "0.8247622", "0.82422256", "0.8088718", "0.7989696", "0.7920805", "0.7832869", "0.77917284", "0.7789659", "0.76852405", "0.76239246"...
0.7572164
23
Verify that the first Launch entry will have all expected fields after a Server Rebuild
def test_launch_entry_fields_on_create_server(self): self.validate_launch_entry_field_values(server=self.rebuilt_server)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_launch_entry_fields_on_rebuild(self):\n self.validate_launch_entry_field_values(\n server=self.rebuilt_server,\n event_launch_server=self.event_launch_rebuilt_server,\n launched_at=self.launched_at_rebuilt_server)", "def test_launch_entry_on_rebuild_server_respons...
[ "0.81207895", "0.79268795", "0.6955217", "0.6627102", "0.6412835", "0.6347759", "0.6204026", "0.61454326", "0.5905115", "0.55958134", "0.5579447", "0.55739534", "0.5570272", "0.55161303", "0.55011386", "0.5451193", "0.54189414", "0.5404436", "0.5387613", "0.5378007", "0.53719...
0.79953957
1
Returns a boolean indicating whether or not the wallet is multisig
def is_multisig(self): return self.key.multisig
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isMultisigScript(scriptVersion, script):\n # Since this is only checking the form of the script, don't extract the\n # public keys to avoid the allocation.\n details = extractMultisigScriptDetails(scriptVersion, script, False)\n return details.valid", "def multi_share_enabled(self) -> bool:\n ...
[ "0.6007225", "0.5783151", "0.5517695", "0.5491802", "0.5221864", "0.51194525", "0.51006013", "0.5094035", "0.5019434", "0.49805722", "0.49805722", "0.48956025", "0.48496148", "0.48159447", "0.48155534", "0.48061487", "0.48011568", "0.47815844", "0.477637", "0.47696465", "0.47...
0.7226874
0
Returns a boolean indicating whether or not this wallet has been loaded
def is_loaded(self): return self.wallet_data is not None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isLoaded(self):\n\t\tif (self.Loaded):\n\t\t\treturn True\n\t\telse:\n\t\t\treturn False", "def isLoaded():\n return _loaded is not None", "def is_loaded(self):\n return self.known_stations != {}", "def loaded(cls):\n return True", "def loadSuccessful(self):\r\n\r\n return (self...
[ "0.7591657", "0.74504095", "0.7215792", "0.69599104", "0.68993765", "0.6893365", "0.68815446", "0.68085515", "0.66722196", "0.65556926", "0.6516103", "0.6516103", "0.650207", "0.64893115", "0.64816463", "0.6479154", "0.6473145", "0.6473145", "0.6468224", "0.6468224", "0.64682...
0.8906152
0
We overridte the torch.nn.Module.to method so that the deep CCA models are sent to the GPU even if they are not in self.children() This method has the same signature as the overriden method
def to(self, device): if self.cca_type == 'classic': for mean in self.mean.values(): mean.to(device) for base_change in self.base_change.values(): base_change.to(device) elif self.cca_type == 'deep': for correlator in self.correlators.values(): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def module_transfer_to_device(self) -> None:\n for name, module in self.modules.items():\n module.to(self.device)\n if self.device.type == 'cuda':\n self.modules[name] = torch.nn.DataParallel(module, self.gpu_ids)\n return", "def __init__(self, id, node_type=Nod...
[ "0.68150854", "0.6004479", "0.598258", "0.59385115", "0.5901991", "0.5842518", "0.5798485", "0.5782124", "0.5775432", "0.5765972", "0.575868", "0.5743006", "0.5738725", "0.57147104", "0.56929713", "0.5679948", "0.56731045", "0.5661532", "0.564101", "0.5629673", "0.5629673", ...
0.5939093
3
Same as forward, but returns a class instead of scores The input, X, can be either a dict or an array, depending on the type of network and fusion
def predict(self, X): scores, dissimilar_features_dict = self(X) probas = F.softmax(scores, dim=1) classes = torch.argmax(probas, dim=1) return scores, classes, dissimilar_features_dict
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self, x):\n out = self.features(x)\n out = out.view(out.size(0), -1)\n out = self.classifier(out)\n return out", "def forward(self, x):\n batch_size = x.shape[0]\n expected_shape = (batch_size, self.num_classes)\n\n out = self.feature_extractor(x)\n ...
[ "0.70795095", "0.70219946", "0.70219946", "0.6962395", "0.6962395", "0.6846841", "0.68180585", "0.6781062", "0.6754771", "0.66954213", "0.66908306", "0.6644112", "0.65738624", "0.65580887", "0.65214753", "0.65093696", "0.64836484", "0.64835024", "0.647479", "0.6454067", "0.64...
0.6259409
35
Return an array of dictionaries for all genes in this geneset.
def to_json(self): return self._dataframe.reset_index().to_json(orient="records")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def all(self):\n genres = []\n for row in self.db.cursor().execute('SELECT genre_id, name FROM genres'):\n genre = {\n 'id' : row[0],\n 'name' : row[1]\n }\n genres.append(genre)\n\n return genres", "def _get_gene_map(self) -> OrderedDict:\n if \"gene\" not in self.da...
[ "0.6908807", "0.6823416", "0.6666162", "0.6664463", "0.6567391", "0.652679", "0.63673955", "0.62588304", "0.6257606", "0.6207553", "0.6151375", "0.6147902", "0.6145195", "0.6098626", "0.6016613", "0.60151005", "0.5968584", "0.59669465", "0.59240186", "0.5915973", "0.5905528",...
0.0
-1
load pretrained word embeddings from the disk
def load_embeddings(path, vocab, source_domain, target_domain, emb_name): pkl = './work/embeddings/%s_%s_%s.pkl' % (source_domain, target_domain, emb_name) if os.path.exists(pkl): print("Load embeddings from existing pkl file %s..." % pkl) # word embeddings weights have been loaded embe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_embeddings():\n return embedding_utils.PretrainedWordEmbeddings(\n lowercase=FLAGS.lowercase,\n embeddings_path=FLAGS.fasttext_embeddings,\n max_vocab_size=FLAGS.max_vocab_size,\n skip_header=True)", "def load_embedding_file(self):\n if self.language == 'en':\n emb...
[ "0.8092851", "0.8047715", "0.78451884", "0.7638054", "0.75392705", "0.74522924", "0.73739296", "0.73253834", "0.72930425", "0.7289413", "0.7287616", "0.7239555", "0.72135115", "0.7199513", "0.71698827", "0.71592486", "0.7139521", "0.7126408", "0.7102826", "0.70784545", "0.707...
0.77417827
3
Yield all prefixes of s. >>> list(prefixes('both')) ['b', 'bo', 'bot', 'both']
def prefixes(s): if s: yield from prefixes(s[:-1]) yield s
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def prefixes(s):\r\n if s:\r\n yield from prefixes(s[:-1]) # First yield prefixes from s[:-1], then yield the last one s.\r\n yield s", "def prefixes(S):\r\n result = set()\r\n for s in S:\r\n for i in range(len(s) + 1):\r\n result.add(s[:i])\r\n return result", "d...
[ "0.7561569", "0.6847686", "0.67807233", "0.6444006", "0.63676876", "0.6310198", "0.62294173", "0.6195503", "0.6067924", "0.5986327", "0.5970709", "0.5955808", "0.5917012", "0.5900017", "0.5865516", "0.58278507", "0.57822204", "0.5753582", "0.5730015", "0.5728158", "0.5726461"...
0.7734767
0
Euclidean distance of two points (x_0, y_0) and (x_1, y_1).
def eucl_dist(x_0, y_0, x_1, y_1): return sqrt((x_1 - x_0)**2 + (y_1 - y_0)**2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def euclidean_distance(x1, y1, x2, y2):\n distance = math.sqrt(((x2 - x1) ** 2) + ((y2 - y1) ** 2))\n return distance", "def euclideanDistance(x1,y1,x2,y2):\n distance = math.sqrt(abs(math.pow((x2-x1),2)) + abs(math.pow((y2-y1),2)))\n return distance", "def euclidian_distance(x1, y1, x2, y2...
[ "0.86894107", "0.8537849", "0.8350644", "0.8316023", "0.8253045", "0.82333994", "0.82213837", "0.81973934", "0.81894666", "0.8186161", "0.8152438", "0.8149112", "0.8144662", "0.80964214", "0.8047051", "0.8034181", "0.8020019", "0.7976255", "0.79448557", "0.7937331", "0.792512...
0.84383744
2
Matches from a set of paths based on acceptable patterns and ignorable patterns.
def match_any_paths(paths, included_patterns=None, excluded_patterns=None, case_sensitive=True): included = ["*"] if included_patterns is None else included_patterns excluded = [] if excluded_patterns is None else excluded_patterns for path in paths: if _match_path(path, set(included), set(excluded...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def filter_paths(paths, included_patterns=None, excluded_patterns=None, case_sensitive=True):\n included = [\"*\"] if included_patterns is None else included_patterns\n excluded = [] if excluded_patterns is None else excluded_patterns\n\n for path in paths:\n if _match_path(path, set(included), set...
[ "0.6930423", "0.6576391", "0.6353927", "0.6342264", "0.61754614", "0.61704755", "0.61702967", "0.6124851", "0.61029595", "0.6082423", "0.6068204", "0.60087115", "0.5983075", "0.5895667", "0.5831922", "0.58124864", "0.580685", "0.57505935", "0.5735855", "0.57120633", "0.568559...
0.73378026
0
Returns information about the existence of the scripts in the script cache. This command accepts one or more SHA1 digests and returns a list of ones or zeros to signal if the scripts are already defined or not inside the script cache. This can be useful before a pipelining operation to ensure that scripts are loaded (a...
def script_exists(self, *hashes): return self._execute([b'SCRIPT', b'EXISTS'] + list(hashes))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_scripts_already_ran(pgconn):\n\n cursor = pgconn.cursor()\n\n cursor.execute(textwrap.dedent(\"\"\"\n select script_path\n from rtapebbletest_schema_version\n \"\"\"))\n\n # Return these as a set, so lookups are a little faster.\n return {row.script_path for row in cursor}"...
[ "0.55317104", "0.5336463", "0.5314171", "0.5301547", "0.5300128", "0.5289836", "0.5273753", "0.52234566", "0.52150434", "0.5197239", "0.5193058", "0.5141179", "0.5129897", "0.5124862", "0.51117516", "0.50858134", "0.50459206", "0.5040405", "0.50155985", "0.5001546", "0.499875...
0.6816878
0
Get topic with pmi.
def getTopicPmi(self, folderpath, numTopic): # get tweets # helper = Utility.Helper(self.rootpath) folderPath = os.path.join(folderpath, 'final') tweets = self.helper.getTweet(folderPath) with codecs.open(os.path.join(self.rootpath, folderPath, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_topic(self):\n return self.topic", "def topic(self):\n return self.config.get('topic', f'{NAMESPACE}/{self.id}')", "def topic(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"topic\")", "def get_parameter(self, topic):\n \n for attr in self....
[ "0.68696165", "0.64921874", "0.6471078", "0.6420331", "0.6405029", "0.6317129", "0.6280842", "0.6243135", "0.6232788", "0.6215747", "0.6203643", "0.6194196", "0.6179269", "0.61575836", "0.61478454", "0.61119115", "0.6105585", "0.60151577", "0.5992994", "0.59633", "0.5855342",...
0.6612745
1
Get corpus as .csv file for further classification.
def getCorpus4Classification(self, folderpath, top=5): folderPath = os.path.join(folderpath, 'final') rankedClusterClaims = self.helper.loadJson( folderPath+"/ranked_cluster_claims.json") representativeClaimToSubject = self.helper.loadJson( folderPath+"/representative_cl...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def export_corpus_csv(corpus,path, delimiter = ',', trans_delimiter = '.'):\n word = corpus.random_word()\n header = sorted(word.descriptors)\n with open(path, encoding='utf-8', mode='w') as f:\n print(delimiter.join(header), file=f)\n for key in corpus.iter_sort():\n print(delimi...
[ "0.6847315", "0.6645845", "0.65709496", "0.64539975", "0.6321269", "0.6282048", "0.6263236", "0.6237937", "0.6115461", "0.6105705", "0.60523635", "0.60328275", "0.6002269", "0.59984237", "0.59540087", "0.59103686", "0.5889208", "0.5883794", "0.5873171", "0.5871999", "0.586708...
0.0
-1
Remove extra whitespaces from text
def reduce_spaces(tweet): text = tweet.strip() text = " ".join(text.split()) return re.sub(' +', ' ', text)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_extra_space(text):\n text = \" \".join(text.split())\n return text", "def del_whitespace(selfs, text):\n\t\treturn text.replace(' ', '')", "def remove_whitespaces(text: str) -> str:\n return text.lstrip().rstrip()", "def _remove_extra_whitespaces(self, text: str) -> str:\n retu...
[ "0.85224587", "0.8470525", "0.83490545", "0.83294195", "0.8307565", "0.8299538", "0.8286804", "0.8221915", "0.8157672", "0.8108128", "0.8056666", "0.7966283", "0.793651", "0.793651", "0.79059696", "0.7782701", "0.77585715", "0.77093023", "0.76691926", "0.7660346", "0.75531036...
0.7268002
45
The TempSensor class initializer.
def __init__(self, name, unit="F") -> None: super().__init__(name) self.unit: str = unit """The temperature unit."""
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, sensor):\n self.sensor = sensor\n self.temperature = None\n self.humitidy = None\n self.update()", "def __init__(self):\n\t\tself.Temperatures = [0]\n\t\tpass", "def __init__(self, temp=21, timer_mode='Off', fan_mode='Auto', fan_swing_mode='Off', master_mode='Heat...
[ "0.77390486", "0.75458467", "0.73768216", "0.7216499", "0.7216499", "0.7216499", "0.70329", "0.696444", "0.692835", "0.68961567", "0.68931395", "0.6873894", "0.67971915", "0.6744998", "0.6632123", "0.6574843", "0.6509469", "0.6450711", "0.64052224", "0.6404268", "0.6390131", ...
0.5966508
75
This function returns a random string which has n length. The alphabets are [09azAZ]. So randstr(n) can return 42^n kinds of strings. randstr(10) > 42^10 = 1.70802e+16 randstr(12) > 42^12 = 3.012947e+19
def randstr(n): alphabets = string.digits + string.letters return ''.join(random.choice(alphabets) for i in xrange(n))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gen_rand_str(n):\n return \"\".join(random.choice(string.ascii_letters) for _ in range(n))", "def random_string(n, alphabet=string.ascii_lowercase):\n return \"\".join(random.choice(alphabet) for _ in range(n))", "def generate_random_string(N):\n return ''.join(random.choice(string.ascii_upper...
[ "0.86577547", "0.8417226", "0.8313579", "0.809194", "0.8063749", "0.798636", "0.79545754", "0.7949776", "0.79040307", "0.79019654", "0.7891512", "0.78810227", "0.78438675", "0.7822679", "0.7815024", "0.7808676", "0.78066933", "0.77945304", "0.77585906", "0.7755603", "0.774508...
0.86733854
0
Remove punctuation, converts all words to lowercase and stems the words.
def normalize(text): removePunctuation = dict((ord(char), None) for char in string.punctuation) return stem_tokens(nltk.word_tokenize(text.lower().translate(removePunctuation)))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lower_and_remove_punc(self):\n table = str.maketrans('', '', punctuation)\n return self.words.lower().translate(table)", "def normalize(s):\r\n def remove_articles(text):\r\n return re.sub(r'\\b(a|an|the)\\b', ' ', text)\r\n\r\n def white_space_fix(text):\r\n return ' '.join...
[ "0.7847613", "0.7604192", "0.7604192", "0.7583281", "0.75671554", "0.74545836", "0.73994726", "0.73895067", "0.73442894", "0.7311007", "0.7308703", "0.72948736", "0.7224363", "0.72016114", "0.7199571", "0.7162001", "0.7117845", "0.7107034", "0.7107034", "0.7093296", "0.709071...
0.7197471
15
Returns `unsqueeze_batch(op(squeeze_batch(inp)))`. Where `squeeze_batch` reshapes `inp` to shape
def squeeze_batch_dims(inp, op, inner_rank, name=None): with ops.name_scope(name, "squeeze_batch_dims", [inp]): inp = ops.convert_to_tensor(inp, name="input") shape = inp.shape inner_shape = shape[-inner_rank:] if not inner_shape.is_fully_defined(): inner_shape = array_ops.shape(inp)[-inner_ran...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_unsqueeze(g, op, block):\n\n x = g.get_node(op.input(\"X\")[0])\n axes = sorted(op.attr(\"axes\"))\n for axis in axes:\n x = _op.expand_dims(x, axis=axis, num_newaxis=1)\n g.add_node(op.output(\"Out\")[0], x)", "def batch_flatten(x):\n shape = x.get_shape().as_list()[1:]\n if...
[ "0.6718441", "0.6534425", "0.6534425", "0.6520653", "0.6520653", "0.64392793", "0.6392382", "0.6352629", "0.63212174", "0.6283865", "0.62636024", "0.61838055", "0.61558735", "0.6145439", "0.6133597", "0.61072767", "0.60191303", "0.5965859", "0.5919871", "0.5900427", "0.589960...
0.73209107
0
Performs `op` on the spacetobatch representation of `input`. This has the effect of transforming sliding window operations into the corresponding "atrous" operation in which the input is sampled at the specified `dilation_rate`.
def with_space_to_batch( input, # pylint: disable=redefined-builtin dilation_rate, padding, op, filter_shape=None, spatial_dims=None, data_format=None): input = ops.convert_to_tensor(input, name="input") # pylint: disable=redefined-builtin input_shape = input.shape def build_op(num_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _with_space_to_batch_call(self, inp, filter): # pylint: disable=redefined-builtin\n # Handle input whose shape is unknown during graph creation.\n input_spatial_shape = None\n input_shape = self.input_shape\n spatial_dims = self.spatial_dims\n if input_shape.ndims is not None:\n input_shap...
[ "0.65705353", "0.61957026", "0.5534044", "0.54305804", "0.53845984", "0.535073", "0.5318044", "0.5289224", "0.5123465", "0.50925934", "0.5089551", "0.5086789", "0.5072465", "0.5068724", "0.5057993", "0.50437266", "0.50276715", "0.49892882", "0.49840266", "0.49763918", "0.4972...
0.80663246
0
Helper function for verifying strides and dilation_rate arguments. This is used by `convolution` and `pool`.
def _get_strides_and_dilation_rate(num_spatial_dims, strides, dilation_rate): if dilation_rate is None: dilation_rate = [1] * num_spatial_dims elif len(dilation_rate) != num_spatial_dims: raise ValueError(f"`len(dilation_rate)` should be {num_spatial_dims}. " f"Received: dilation_rate={...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testStrideError(self, use_bias):\n\n snt.DepthwiseConv2D(channel_multiplier=1, kernel_shape=3, stride=1,\n use_bias=use_bias)\n snt.DepthwiseConv2D(channel_multiplier=1, kernel_shape=3, stride=[1] * 2,\n use_bias=use_bias)\n snt.DepthwiseConv2D(channel_mul...
[ "0.61039317", "0.6080088", "0.5989842", "0.5955495", "0.5794096", "0.5626163", "0.55502445", "0.5482819", "0.5470505", "0.5446638", "0.5445491", "0.5374058", "0.5358085", "0.53514653", "0.53472173", "0.5346049", "0.53052014", "0.52923936", "0.5289988", "0.52825266", "0.526620...
0.6759871
0
r"""Computes a 2D depthwise convolution. Given an input tensor of shape `[batch, in_height, in_width, in_channels]` and a filter / kernel tensor of shape `[filter_height, filter_width, in_channels, channel_multiplier]`, containing `in_channels` convolutional filters of depth 1, `depthwise_conv2d` applies a different fi...
def depthwise_conv2d_native( # pylint: disable=redefined-builtin,dangerous-default-value input, filter, strides, padding, data_format="NHWC", dilations=[1, 1, 1, 1], name=None): padding, explicit_paddings = convert_padding(padding) return gen_nn_ops.depthwise_conv2d_native( input,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def depthwise_conv2d(\n input,\n weight,\n bias=None,\n stride=1,\n padding=0,\n dilation=1,\n):\n return _conv('DepthwiseConv', utils._pair, **locals())", "def conv2d(inputs, out_channels, kernel_size, strides=[1, 1], padding='SAME',\n weight_initializer=he_initializer, bias_value...
[ "0.7397858", "0.7311212", "0.7264918", "0.7112354", "0.70384914", "0.6963098", "0.695776", "0.6924378", "0.69034797", "0.68666095", "0.67867714", "0.6776433", "0.6775594", "0.67732966", "0.67587394", "0.67548376", "0.67366564", "0.6723427", "0.6657302", "0.6605076", "0.658038...
0.7351828
1
The transpose of `conv3d`. This operation is sometimes called "deconvolution" after (Zeiler et al., 2010), but is really the transpose (gradient) of `conv3d` rather than an actual deconvolution.
def conv3d_transpose( value, filter=None, # pylint: disable=redefined-builtin output_shape=None, strides=None, padding="SAME", data_format="NDHWC", name=None, input=None, # pylint: disable=redefined-builtin filters=None, dilations=None): filter = deprecated_argument_lookup("f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conv_transpose3d(\n input,\n weight,\n bias=None,\n stride=1,\n padding=0,\n output_padding=0,\n groups=1,\n dilation=1,\n):\n return _conv_transpose('ConvTranspose', utils._triple, **locals())", "def conv3d_transpose_v2(input, # pylint: disable=redefined-builtin\n ...
[ "0.74245274", "0.66827804", "0.6679721", "0.6620681", "0.65944713", "0.65930057", "0.6556234", "0.65545493", "0.65193033", "0.6377529", "0.62983596", "0.62724406", "0.62225056", "0.6216491", "0.6177879", "0.6131803", "0.6131803", "0.6121568", "0.6100586", "0.6100586", "0.6100...
0.627907
11
The transpose of `conv3d`. This operation is sometimes called "deconvolution" after (Zeiler et al., 2010), but is really the transpose (gradient) of `conv3d` rather than an actual deconvolution.
def conv3d_transpose_v2(input, # pylint: disable=redefined-builtin filters, output_shape, strides, padding="SAME", data_format="NDHWC", dilations=None, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conv_transpose3d(\n input,\n weight,\n bias=None,\n stride=1,\n padding=0,\n output_padding=0,\n groups=1,\n dilation=1,\n):\n return _conv_transpose('ConvTranspose', utils._triple, **locals())", "def CustomConv3DTranspose(x_in, nf, strides=2, kernel_size = 3):\r\n\tx_out = Conv3DT...
[ "0.74229854", "0.66793394", "0.66213435", "0.65934765", "0.6591609", "0.655657", "0.65529376", "0.6519125", "0.63765097", "0.6298423", "0.62791413", "0.62725365", "0.6221178", "0.621647", "0.61776495", "0.6131757", "0.6131757", "0.61208844", "0.6100425", "0.6100425", "0.61004...
0.66818315
1
The transpose of `convolution`. This operation is sometimes called "deconvolution" after (Zeiler et al., 2010), but is really the transpose (gradient) of `conv3d` rather than an actual deconvolution.
def conv_transpose(input, # pylint: disable=redefined-builtin filters, output_shape, strides, padding="SAME", data_format=None, dilations=None, name=None): with ops.name_scope(name, "c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def conv_transpose3d(\n input,\n weight,\n bias=None,\n stride=1,\n padding=0,\n output_padding=0,\n groups=1,\n dilation=1,\n):\n return _conv_transpose('ConvTranspose', utils._triple, **locals())", "def CustomConv3DTranspose(x_in, nf, strides=2, kernel_size = 3):\r\n\tx_out = Conv3DT...
[ "0.7098478", "0.6571258", "0.65425855", "0.65141743", "0.6408076", "0.6379093", "0.63717324", "0.63716936", "0.6360015", "0.63190794", "0.6300746", "0.6238246", "0.6218946", "0.615293", "0.6148239", "0.6147321", "0.6118739", "0.6079727", "0.6076198", "0.6042877", "0.60407764"...
0.6136933
16
Computes Concatenated ReLU. Concatenates a ReLU which selects only the positive part of the activation with a ReLU which selects only the negative part of the activation. Note that as a result this nonlinearity doubles the depth of the activations.
def crelu(features, name=None, axis=-1): with ops.name_scope(name, "CRelu", [features]) as name: features = ops.convert_to_tensor(features, name="features") c = array_ops.concat([features, -features], axis, name=name) # pylint: disable=invalid-unary-operand-type return gen_nn_ops.relu(c)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def grad_ReLU(self):\n y = self.x\n y[y<=0] = 0\n y[y>0] = 1\n return y\n raise NotImplementedError(\"ReLU gradient not implemented\")", "def lrelu(self):\n return self.add_layer(lrelu)", "def activation_ReLU(self):\n self.value = max(0, self.value)", "def gra...
[ "0.67294675", "0.6671572", "0.64201677", "0.6418029", "0.62927157", "0.6265992", "0.62437457", "0.61760783", "0.61603147", "0.6159588", "0.61272466", "0.6118365", "0.60635304", "0.6049202", "0.60435", "0.6034914", "0.59939367", "0.5984993", "0.5943914", "0.5916054", "0.591209...
0.5616839
64
Compute the Leaky ReLU activation function.
def leaky_relu(features, alpha=0.2, name=None): with ops.name_scope(name, "LeakyRelu", [features, alpha]) as name: features = ops.convert_to_tensor(features, name="features") if features.dtype.is_integer: features = math_ops.cast(features, dtypes.float32) if isinstance(alpha, np.ndarray): alph...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_leaky_relu_activation(self):\n self.assertEqual(\n [-0.0050, 0.5000], list(af.LeakyRelu(0.01).output(np.array([-0.5, 0.5]))))\n self.assertEqual([0.01, 1], list(af.LeakyRelu(\n 0.01).derivative(np.array([-0.5, 0.5]))))", "def activation_ReLU(self):\n self.value...
[ "0.7099581", "0.703163", "0.7020819", "0.6925728", "0.69070184", "0.68698215", "0.68664426", "0.68197566", "0.6802242", "0.68016744", "0.6797465", "0.6745097", "0.6745097", "0.6732075", "0.67222315", "0.67126656", "0.67032737", "0.66862845", "0.6683829", "0.6683007", "0.66730...
0.6177858
90
Helper function for ops that accept and return 2d inputs of same shape. It reshapes and transposes the inputs into a 2D Tensor and then invokes the given function. The output would be transposed and reshaped back. If the given function returns a tuple of tensors, each of them will be transposed and reshaped.
def _wrap_2d_function(inputs, compute_op, dim=-1, name=None): def _swap_axis(input_tensor, dim_index, last_index, name=None): """Swaps logits's dim_index and last_index.""" return array_ops.transpose( input_tensor, array_ops.concat([ math_ops.range(dim_index), [last_index], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wrap(func, *args, unsqueeze=False):\n\n # Convert input types where applicable\n args = list(args)\n for i, arg in enumerate(args):\n if type(arg) == np.ndarray:\n args[i] = torch.from_numpy(arg)\n if unsqueeze:\n args[i] = args[i].unsqueeze(0)\n\n result...
[ "0.64542925", "0.642639", "0.6359442", "0.62516344", "0.6192334", "0.61528665", "0.6092715", "0.6038481", "0.6026908", "0.6022252", "0.599349", "0.589647", "0.5885018", "0.5878939", "0.5852289", "0.5838391", "0.5826835", "0.581348", "0.57979023", "0.5736759", "0.5700128", "...
0.6707056
0
Computes softmax activations. Used for multiclass predictions. The sum of all outputs generated by softmax is 1. This function performs the equivalent of ```python softmax = tf.exp(logits) / tf.reduce_sum(tf.exp(logits), axis, keepdims=True) ```
def softmax_v2(logits, axis=None, name=None): if axis is None: axis = -1 return _wrap_2d_function(logits, gen_nn_ops.softmax, axis, name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def softmax(x):\n return np.exp(x) / np.sum(np.exp(x), axis=1, keepdims=True)", "def softmax(inputs):\n return np.exp(inputs) / float(sum(np.exp(inputs)))", "def softmax(inputs):\n return np.exp(inputs) / float(sum(np.exp(inputs)))", "def softmax(x):\n return np.exp(x) / np.sum(np.exp(x), axis=1, k...
[ "0.8138454", "0.8106893", "0.8106893", "0.8103695", "0.8013667", "0.79889274", "0.78784555", "0.7862353", "0.7848741", "0.7848741", "0.7848741", "0.7848741", "0.7848741", "0.7848741", "0.7848741", "0.7848741", "0.78269583", "0.7817007", "0.77751046", "0.7771511", "0.776328", ...
0.0
-1
Computes log softmax activations. For each batch `i` and class `j` we have logsoftmax = logits log(reduce_sum(exp(logits), axis))
def log_softmax(logits, axis=None, name=None, dim=None): axis = deprecation.deprecated_argument_lookup("axis", axis, "dim", dim) if axis is None: axis = -1 return _wrap_2d_function(logits, gen_nn_ops.log_softmax, axis, name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_softmax_nd(logits, axes=(-1,)):\n logits -= tf.reduce_max(logits, axis=axes, keepdims=True)\n return logits - tf.reduce_logsumexp(logits, axis=axes, keepdims=True)", "def softmax_ndarray(logits: jnp.DeviceArray) -> jnp.DeviceArray:\n assert len(logits.shape) == 2\n # Normalise for better stabilit...
[ "0.76322865", "0.746993", "0.7230063", "0.7211278", "0.71362007", "0.71228236", "0.7065765", "0.7053107", "0.69787186", "0.6934435", "0.68790966", "0.6866154", "0.68490297", "0.6820983", "0.6819095", "0.67911583", "0.67911583", "0.6779187", "0.67745435", "0.6767171", "0.67637...
0.7195816
4
Computes log softmax activations. For each batch `i` and class `j` we have logsoftmax = logits log(reduce_sum(exp(logits), axis))
def log_softmax_v2(logits, axis=None, name=None): if axis is None: axis = -1 return _wrap_2d_function(logits, gen_nn_ops.log_softmax, axis, name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_softmax_nd(logits, axes=(-1,)):\n logits -= tf.reduce_max(logits, axis=axes, keepdims=True)\n return logits - tf.reduce_logsumexp(logits, axis=axes, keepdims=True)", "def softmax_ndarray(logits: jnp.DeviceArray) -> jnp.DeviceArray:\n assert len(logits.shape) == 2\n # Normalise for better stabilit...
[ "0.76331776", "0.7470995", "0.7229753", "0.7211772", "0.7197805", "0.71368617", "0.7123612", "0.7067114", "0.705407", "0.6978195", "0.69336134", "0.68784106", "0.68493646", "0.68219817", "0.68192255", "0.67913514", "0.67913514", "0.6779084", "0.6774613", "0.67666173", "0.6764...
0.68676275
12
Computes softmax cross entropy between `logits` and `labels`. Measures the probability error in discrete classification tasks in which the classes are mutually exclusive (each entry is in exactly one class). For
def softmax_cross_entropy_with_logits_v2(labels, logits, axis=-1, name=None): return softmax_cross_entropy_with_logits_v2_helper( labels=labels, logits=logits, axis=axis, name=name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def softmax_cross_entropy_loss(logit, labels):\n p = softmax(logit)\n loss_i = - labels * np.log(p + 1e-8)\n return np.mean(loss_i)", "def cross_entropy_loss(self, logits, labels):\n return F.cross_entropy(logits, labels)", "def cross_entropy_loss(logits, labels, label_smoothing=0., dtype=jnp.f...
[ "0.84107345", "0.7927014", "0.7697431", "0.760659", "0.7580251", "0.7531908", "0.7524282", "0.7450999", "0.7432497", "0.742975", "0.737596", "0.7335546", "0.73315597", "0.73301613", "0.7325932", "0.7325932", "0.7317973", "0.7297712", "0.72831094", "0.7266739", "0.72504884", ...
0.721355
24
Computes softmax cross entropy between `logits` and `labels`. Measures the probability error in discrete classification tasks in which the classes are mutually exclusive (each entry is in exactly one class). For
def softmax_cross_entropy_with_logits_v2_helper( labels, logits, axis=None, name=None, dim=None): # TODO(pcmurray) Raise an error when the labels do not sum to 1. Note: This # could break users who call this with bad labels, but disregard the bad # results. axis = deprecated_argument_lookup("axis", axis, "d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def softmax_cross_entropy_loss(logit, labels):\n p = softmax(logit)\n loss_i = - labels * np.log(p + 1e-8)\n return np.mean(loss_i)", "def cross_entropy_loss(self, logits, labels):\n return F.cross_entropy(logits, labels)", "def cross_entropy_loss(logits, labels, label_smoothing=0., dtype=jnp.f...
[ "0.8411002", "0.79268396", "0.76967716", "0.76059747", "0.75797135", "0.75319976", "0.75235415", "0.74520904", "0.74311614", "0.74304515", "0.7375553", "0.73350877", "0.7330513", "0.733048", "0.7324864", "0.7324864", "0.72970533", "0.72827137", "0.7266514", "0.72493476", "0.7...
0.73179185
16
Computes softmax cross entropy between `logits` and `labels`. Measures the probability error in discrete classification tasks in which the classes are mutually exclusive (each entry is in exactly one class). For
def softmax_cross_entropy_with_logits( labels=None, logits=None, dim=-1, name=None, axis=None): dim = deprecated_argument_lookup("axis", axis, "dim", dim) _ensure_xent_args("softmax_cross_entropy_with_logits", labels, logits) with ops.name_scope(name, "softmax_cross_entropy_with_logits_sg", ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def softmax_cross_entropy_loss(logit, labels):\n p = softmax(logit)\n loss_i = - labels * np.log(p + 1e-8)\n return np.mean(loss_i)", "def cross_entropy_loss(self, logits, labels):\n return F.cross_entropy(logits, labels)", "def cross_entropy_loss(logits, labels, label_smoothing=0., dtype=jnp.f...
[ "0.8411184", "0.79274523", "0.7697965", "0.76064575", "0.758026", "0.75316054", "0.75254136", "0.7451711", "0.7433356", "0.74305826", "0.7376726", "0.73357004", "0.7332774", "0.73309577", "0.7327111", "0.7327111", "0.7318131", "0.7298851", "0.7283311", "0.72665316", "0.725024...
0.7149077
32
Computes sparse softmax cross entropy between `logits` and `labels`. Measures the probability error in discrete classification tasks in which the classes are mutually exclusive (each entry is in exactly one class). For
def sparse_softmax_cross_entropy_with_logits( labels=None, logits=None, name=None): _ensure_xent_args("sparse_softmax_cross_entropy_with_logits", labels, logits) # TODO(pcmurray) Raise an error when the label is not an index in # [0, num_classes). Note: This could break users who call this with bad ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def softmax_cross_entropy_loss(logit, labels):\n p = softmax(logit)\n loss_i = - labels * np.log(p + 1e-8)\n return np.mean(loss_i)", "def cross_entropy_loss(logits, labels, label_smoothing=0., dtype=jnp.float32):\n num_classes = logits.shape[-1]\n labels = jax.nn.one_hot(labels, num_classes, dtyp...
[ "0.8026245", "0.7663195", "0.759598", "0.7554181", "0.7490599", "0.74778795", "0.7460082", "0.74335146", "0.73739445", "0.73720515", "0.73564434", "0.73234993", "0.73234993", "0.7299513", "0.7296221", "0.7244808", "0.71571517", "0.7146539", "0.7139635", "0.71145", "0.71026355...
0.79563314
1
Computes sparse softmax cross entropy between `logits` and `labels`. Measures the probability error in discrete classification tasks in which the classes are mutually exclusive (each entry is in exactly one class). For
def sparse_softmax_cross_entropy_with_logits_v2(labels, logits, name=None): return sparse_softmax_cross_entropy_with_logits( labels=labels, logits=logits, name=name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def softmax_cross_entropy_loss(logit, labels):\n p = softmax(logit)\n loss_i = - labels * np.log(p + 1e-8)\n return np.mean(loss_i)", "def sparse_softmax_cross_entropy_with_logits(\n labels=None,\n logits=None,\n name=None):\n _ensure_xent_args(\"sparse_softmax_cross_entropy_with_logits\", lab...
[ "0.80249685", "0.7955678", "0.766295", "0.7595688", "0.75535417", "0.7490263", "0.7476721", "0.74328446", "0.737353", "0.7371765", "0.7355237", "0.7323204", "0.7323204", "0.7298193", "0.72958666", "0.72433376", "0.71564645", "0.7145351", "0.71389747", "0.7113666", "0.71022815...
0.7459861
7
Performs max pooling on the input. For a given window of `ksize`, takes the maximum value within that window. Used for reducing computation and preventing overfitting.
def max_pool_v2(input, ksize, strides, padding, data_format=None, name=None): if input.shape is not None: n = len(input.shape) - 2 elif data_format is not None: n = len(data_format) - 2 else: raise ValueError( "`input` must have a static shape or a data format must be given. " f"Receiv...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_pool(value,\n ksize,\n strides,\n padding,\n data_format=\"NHWC\",\n name=None,\n input=None): # pylint: disable=redefined-builtin\n value = deprecation.deprecated_argument_lookup(\"input\", input, \"value\", value)\n with ops.name_...
[ "0.73746395", "0.7039238", "0.68718016", "0.683834", "0.6830746", "0.6781319", "0.6776956", "0.6650215", "0.6646052", "0.6643977", "0.6631067", "0.65956354", "0.6580649", "0.656189", "0.65605026", "0.65162826", "0.63907623", "0.6370196", "0.6357833", "0.63539624", "0.634254",...
0.6878052
2
Performs max pooling on the input and outputs both max values and indices. The indices in `argmax` are flattened, so that a maximum value at position
def max_pool_with_argmax_v2( input, # pylint: disable=redefined-builtin ksize, strides, padding, data_format="NHWC", output_dtype=dtypes.int64, include_batch_in_index=False, name=None): if data_format != "NHWC": raise ValueError("`data_format` values other than 'NHWC' are not " ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_pool(inputs, window_shape, strides=None, padding=\"VALID\"):\n y = pool(inputs, -jnp.inf, lax.max, window_shape, strides, padding)\n return y", "def max_pool_forward_naive(x, pool_param):\n out = None\n ###########################################################################\n # TODO: Imple...
[ "0.7299768", "0.71923697", "0.7190021", "0.71566445", "0.71323276", "0.70956695", "0.7050178", "0.699698", "0.69608414", "0.6946451", "0.6943395", "0.6928642", "0.6897165", "0.68956685", "0.6890593", "0.6861154", "0.68609893", "0.685326", "0.68455577", "0.6832859", "0.6790811...
0.68542325
17
Calculates the compute resources needed for Conv3D.
def _calc_conv3d_flops(graph, node): input_shape = graph_util.tensor_shape_from_node_def_name(graph, node.input[0]) input_shape.assert_is_fully_defined() filter_shape = graph_util.tensor_shape_from_node_def_name( graph, node.input[1]) filter_shape.assert_is_fully_defined() output_shape = graph_util.tens...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def c3d(self):\n model = Sequential()\n # 1st layer group\n model.add(Conv3D(64, 3, 3, 3, activation='relu',\n border_mode='same', name='conv1',\n subsample=(1, 1, 1),\n input_shape=self.input_shape))\n model.add(Ma...
[ "0.6389271", "0.5940744", "0.54207134", "0.53863925", "0.53618324", "0.53466153", "0.53132355", "0.52856517", "0.52815866", "0.5262921", "0.524355", "0.5228246", "0.5216426", "0.52150923", "0.5192296", "0.5191852", "0.51742053", "0.5156763", "0.5148889", "0.5148889", "0.51479...
0.0
-1
Computes matmul(x, weights) + biases.
def xw_plus_b(x, weights, biases, name=None): # pylint: disable=invalid-name with ops.name_scope(name, "xw_plus_b", [x, weights, biases]) as name: x = ops.convert_to_tensor(x, name="x") weights = ops.convert_to_tensor(weights, name="weights") biases = ops.convert_to_tensor(biases, name="biases") mm =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def xw_plus_b_v1(x, weights, biases, name=None):\n with ops.name_scope(name, \"xw_plus_b_v1\", [x, weights, biases]) as name:\n x = ops.convert_to_tensor(x, name=\"x\")\n weights = ops.convert_to_tensor(weights, name=\"weights\")\n biases = ops.convert_to_tensor(biases, name=\"biases\")\n mm = math_op...
[ "0.70692927", "0.70688856", "0.69988126", "0.6936371", "0.68082696", "0.6774858", "0.6680569", "0.6657162", "0.6622451", "0.6460455", "0.6443272", "0.643641", "0.64176685", "0.638659", "0.634765", "0.6335504", "0.63313025", "0.6307932", "0.6288206", "0.62761575", "0.62728894"...
0.7268296
0
Computes matmul(x, weights) + biases. This is a deprecated version of that will soon be removed.
def xw_plus_b_v1(x, weights, biases, name=None): with ops.name_scope(name, "xw_plus_b_v1", [x, weights, biases]) as name: x = ops.convert_to_tensor(x, name="x") weights = ops.convert_to_tensor(weights, name="weights") biases = ops.convert_to_tensor(biases, name="biases") mm = math_ops.matmul(x, weight...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self, input):\r\n output = np.matmul(input, self.weights) + bias\r\n return output", "def xw_plus_b(x, weights, biases, name=None): # pylint: disable=invalid-name\n with ops.name_scope(name, \"xw_plus_b\", [x, weights, biases]) as name:\n x = ops.convert_to_tensor(x, name=\"x\")\n ...
[ "0.6782106", "0.6663224", "0.65982527", "0.64747626", "0.6421178", "0.64141035", "0.6410957", "0.61261904", "0.6124271", "0.60882235", "0.60681707", "0.60553795", "0.6023623", "0.595807", "0.5953184", "0.593655", "0.5929054", "0.59283334", "0.5925662", "0.5905526", "0.5867577...
0.6489619
3
Finds values and indices of the `k` largest entries for the last dimension. If the input is a vector (rank=1), finds the `k` largest entries in the vector and outputs their values and indices as vectors. Thus `values[j]` is the `j`th largest entry in `input`, and its index is `indices[j]`. >>> result = tf.math.top_k([1...
def top_k(input, k=1, sorted=True, index_type=dtypes.int32, name=None): # pylint: disable=redefined-builtin return gen_nn_ops.top_kv2( input, k=k, sorted=sorted, index_type=index_type, name=name )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _my_top_k(x, k):\n if k > 10:\n return tf.nn.top_k(x, k)\n values = []\n indices = []\n depth = tf.shape(x)[1]\n for i in range(k):\n values.append(tf.reduce_max(x, 1))\n argmax = tf.argmax(x, 1)\n indices.append(argmax)\n if i + 1 < k:\n x += tf.one...
[ "0.7920001", "0.75626767", "0.7425223", "0.73994", "0.7309494", "0.72376704", "0.71386784", "0.71071374", "0.70887905", "0.703988", "0.7019873", "0.70146865", "0.6956617", "0.6848324", "0.68397254", "0.6773355", "0.6714459", "0.6642411", "0.65589225", "0.65529674", "0.6533885...
0.7688391
1
r"""Says whether the targets are in the top `K` predictions. This outputs a `batch_size` bool array, an entry `out[i]` is `true` if the prediction for the target class is finite (not inf, inf, or nan) and among the top `k` predictions among all predictions for example `i`. Note that the behavior of `InTopK` differs fro...
def in_top_k(predictions, targets, k, name=None): with ops.name_scope(name, "in_top_k"): return gen_nn_ops.in_top_kv2(predictions, targets, k, name=name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def in_top_k_v2(targets, predictions, k, name=None):\n return in_top_k(predictions, targets, k, name)", "def accuracy_topk(output, target, topk=(5,10)):\n maxk = max(topk)\n batch_size = target.size(0)\n\n _, pred = output.topk(maxk, 1, True, True)\n pred = pred.t()\n correct = pred.eq(target.vie...
[ "0.7797892", "0.705764", "0.69662607", "0.68613386", "0.6766293", "0.6698212", "0.66618526", "0.66283095", "0.6550935", "0.65468055", "0.65454286", "0.65359557", "0.6532391", "0.6528047", "0.6518964", "0.6511669", "0.6511414", "0.64732873", "0.6472346", "0.6471787", "0.645912...
0.7592584
1
Outputs whether the targets are in the top `K` predictions. This outputs a `batch_size` bool array, an entry `out[i]` is `true` if the prediction for the target class is finite (not inf, inf, or nan) and among the top `k` predictions among all predictions for example `i`. `predictions` does not have to be normalized. N...
def in_top_k_v2(targets, predictions, k, name=None): return in_top_k(predictions, targets, k, name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def in_top_k(predictions, targets, k, name=None):\n with ops.name_scope(name, \"in_top_k\"):\n return gen_nn_ops.in_top_kv2(predictions, targets, k, name=name)", "def accuracy_topk(output, target, topk=(5,10)):\n maxk = max(topk)\n batch_size = target.size(0)\n\n _, pred = output.topk(maxk, 1, True,...
[ "0.80303186", "0.70900595", "0.6966324", "0.6923994", "0.6843985", "0.6843605", "0.6783928", "0.6768638", "0.66348547", "0.6430982", "0.6425129", "0.64204067", "0.64144325", "0.64091593", "0.63762414", "0.6367621", "0.6355939", "0.6353064", "0.635304", "0.63501716", "0.635014...
0.7900088
1
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`.
def plot_confusion_matrix(nro_experimento,nro_iteracao,y_true, y_pred, classes, normalize=False, title=None, cmap=plot.cm.Blues, ): if not title: if normalize: title = 'Normalized confusion ma...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n...
[ "0.8194366", "0.8095442", "0.8029135", "0.8019134", "0.7993755", "0.7991176", "0.79808146", "0.79755133", "0.79609716", "0.7956584", "0.79375756", "0.79346216", "0.79343396", "0.7931212", "0.7926087", "0.7924503", "0.7923946", "0.79228765", "0.79227114", "0.7921956", "0.79178...
0.0
-1
Calculate the great circle distance between two points on the earth (specified in decimal degrees)
def get_distance_from_point(long1, lati1, long2, lati2): # convert decimal degrees to radians lon1, lat1, lon2, lat2 = map(radians, [long1, lati1, long2, lati2]) # haversine formula dlon = lon2 - lon1 dlat = lat2 - lat1 a = sin(dlat / 2) ** 2 + cos(lat1) * cos(lat2) * sin(dlon / 2) ** 2 c =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def great_circle(lat_1, long_1, lat_2, long_2):\n long_1 = m.radians(long_1)\n lat_1 = m.radians(lat_1)\n long_2 = m.radians(long_2)\n lat_2 = m.radians(lat_2)\n\n d = 2 * 6367.45 * m.asin(\n m.sqrt(haversine(lat_2 - lat_1)\n + m.cos(lat_1)*m.cos(lat_2) *\n haversine(long...
[ "0.81450045", "0.7863265", "0.76322985", "0.76064754", "0.75978696", "0.75965863", "0.75944835", "0.75720793", "0.75630087", "0.7555095", "0.7528691", "0.7517629", "0.7492963", "0.7467739", "0.7452678", "0.7434477", "0.73914117", "0.7357736", "0.73484355", "0.73318124", "0.73...
0.67196596
98
autoCanny(img, sigma=0.33) > Image with Edges and threshold values
def autoCanny(image, sigma=0.33, retTh=False): # compute the median of the single channel pixel intensities v = np.median(image) std = np.std(image) # apply automatic Canny edge detection using the computed median lower = int(max(0, (1.0 - sigma) * v) - (std * .75)) upper = int(min(255, (1.0 +...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def auto_canny(image, sigma=0.4):\n v = np.median(image)\n lower = int(max(0, (1.0 - sigma) * v))\n upper = int(min(255, (1.0 + sigma) * v))\n edged = Canny(image, lower, upper)\n return edged", "def canny(img, kernel_size=5, sigma=1.4, high=20, low=15):\n ### YOUR CODE HERE\n gaussiankernel...
[ "0.83608705", "0.8222785", "0.80608535", "0.7962752", "0.7962752", "0.7962752", "0.7962752", "0.7962752", "0.7962752", "0.7962752", "0.7962752", "0.7962752", "0.7962752", "0.7962752", "0.7962752", "0.7962752", "0.7962752", "0.7962752", "0.7845488", "0.77756244", "0.773869", ...
0.7819784
19
findAndDrawContours(edgedImg, originalImg, color=(255, 255, 255), thickness=2, area = 500) > Contours of Img
def findAndDrawContours(edgedImg, originalImg, color=(255, 255, 255), thickness=2, area=500): # RETR_EXTERNAL retrieves all contours without # any hierarchical relationships # RETR_EXTERNAL = 0, CHAIN_APPROX_NO...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def drawContours(img, cnt, color=(0, 255, 0), thickness=2):\n\tcv2.drawContours(img, cnt, -1, color, thickness)", "def draw_contours(self, image, maskImg):\r\n # Required variables..\r\n x, y, width, height = 0, 0, 0, 0\r\n # Find contours..\r\n contours, hierarchy = cv2.findContours(...
[ "0.7463013", "0.7265823", "0.7001685", "0.6989482", "0.69844264", "0.6954437", "0.6893674", "0.6800582", "0.66703916", "0.6657626", "0.6622555", "0.66153437", "0.6610394", "0.658886", "0.6541556", "0.6515351", "0.6478993", "0.6470566", "0.6406145", "0.63605255", "0.63484544",...
0.87131894
0
Initializes Dense Feedback module of the Feedback MultINN model.
def _init_feedback(self): self._feedback_layer = DNN( num_units=self._params['generator']['feedback'], activation=tf.nn.sigmoid, kernel_initializer=tf.contrib.layers.xavier_initializer() )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, input_dim):\n super(ps_FNNDenoiser, self).__init__()\n\n self._input_dim = input_dim\n\n self.fnn_enc = Linear(self._input_dim, int(self._input_dim / 2))\n self.fnn_dec = Linear(int(self._input_dim / 2), self._input_dim)\n\n self.initialize_module()", "def in...
[ "0.6575901", "0.651328", "0.63587683", "0.62812436", "0.625933", "0.6255916", "0.6212325", "0.62055093", "0.62013054", "0.6164308", "0.61639035", "0.61522144", "0.6149103", "0.61272985", "0.608981", "0.60770434", "0.60669965", "0.6062045", "0.6055949", "0.60496914", "0.603836...
0.71804065
0
Building the Feedback MultINN Generators and the Feedback module. Inputs to the Generators are outputs from the Encoders, concatenated with the stacked encoded inputs passed through the Feedback layer (module). Feedback module can be a Dense NN (Feedback MultINN), or a Recurrent NN (FeedbackRNN MultINN).
def _build_generators(self, mode='eval'): # Stacking encoded inputs with tf.variable_scope(f'{get_current_scope()}encodings/stacked/'): x_encoded_stack = tf.stack(self._x_encoded, axis=3) self._x_encoded_stack = tf.reshape( x_encoded_stack, tf.conc...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _build(self):\n if self.attn:\n self.Attn = AttentionNet(self.dim_b1, channels=self.channels, name='Attn')\n self.predsb1 = self.Attn(self.xb1, is_training=self.is_training)\n self.predsb2 = self.Attn(self.xb2, is_training=self.is_training, reuse=True)\n #TODO...
[ "0.64584595", "0.5957727", "0.59120554", "0.58997375", "0.5845684", "0.5841561", "0.5834954", "0.5810479", "0.5763015", "0.5749954", "0.573643", "0.5722226", "0.571012", "0.5701102", "0.5691726", "0.56910396", "0.5681814", "0.5666829", "0.56604195", "0.5628055", "0.5627929", ...
0.6261502
1
An list of the Feedback MultINN trainable feedback module variables.
def trainable_feedback_variables(self): return self._trainable_feedback_variables
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collect_trainable_variables(modules):\n if not isinstance(modules, (list, tuple)):\n modules = [modules]\n\n var_list = []\n for mod in modules:\n add_variable(mod.trainable_variables, var_list)\n\n return var_list", "def get_variables(self) -> typing.List:\n parts = (self.ne...
[ "0.66285884", "0.6527203", "0.65088534", "0.6417772", "0.6356927", "0.628504", "0.62136626", "0.6132827", "0.6086009", "0.60141164", "0.59969753", "0.59017146", "0.5891624", "0.58395594", "0.5832678", "0.5725407", "0.57247716", "0.5714408", "0.5710039", "0.5703108", "0.569076...
0.744262
0
Compute dot product kernel function.
def __call__(self, f1, f2): r = 0.0 for f in f1: if f in f2: r += f1[f] * f2[f] return r
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dot_product(x, kernel):\n return K.squeeze(K.dot(x, K.expand_dims(kernel)), axis=-1)", "def dot_product(x, kernel):\r\n if K.backend() == 'tensorflow':\r\n return K.squeeze(K.dot(x, K.expand_dims(kernel)), axis=-1)\r\n else:\r\n return K.dot(x, kernel)", "def dot_product(x, kerne...
[ "0.80516016", "0.78872204", "0.7862523", "0.7862523", "0.7862523", "0.7862523", "0.78513277", "0.78501874", "0.70868164", "0.7003607", "0.6881869", "0.6793582", "0.67901635", "0.67553395", "0.67409223", "0.6739991", "0.6736105", "0.6706804", "0.6687847", "0.666888", "0.665679...
0.0
-1
Compute dot product kernel function.
def __call__(self, f1, f2): # return len(f1.set & f2.set) return len(set(f1.features) & set(f2.features))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dot_product(x, kernel):\n return K.squeeze(K.dot(x, K.expand_dims(kernel)), axis=-1)", "def dot_product(x, kernel):\r\n if K.backend() == 'tensorflow':\r\n return K.squeeze(K.dot(x, K.expand_dims(kernel)), axis=-1)\r\n else:\r\n return K.dot(x, kernel)", "def dot_product(x, kerne...
[ "0.80516016", "0.78872204", "0.7862523", "0.7862523", "0.7862523", "0.7862523", "0.78513277", "0.78501874", "0.70868164", "0.7003607", "0.6881869", "0.6793582", "0.67901635", "0.67553395", "0.67409223", "0.6739991", "0.6736105", "0.6706804", "0.6687847", "0.666888", "0.665679...
0.0
-1
Returns a list of the column names in a pandas DataFrame that have the dtype float (of any precision). Note that the pandas DataFrame cannot have duplicate column names.
def get_float_column_names(df): if not isinstance(df, pd.DataFrame): msg = 'df of type="{}" is not a pandas DataFrame' raise TypeError(msg.format(str(type(df)))) if len(set(df.columns)) != len(df.columns): msg = 'df contains duplicated column names which is not supported' raise V...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_non_float_column_names(df):\n if not isinstance(df, pd.DataFrame):\n msg = 'df of type=\"{}\" is not a pandas DataFrame'\n raise TypeError(msg.format(str(type(df))))\n if len(set(df.columns)) != len(df.columns):\n msg = 'df contains duplicated column names which is not supported'...
[ "0.79489094", "0.7057269", "0.66207606", "0.65314066", "0.6424013", "0.63796335", "0.6282522", "0.6235834", "0.62305707", "0.6197933", "0.6133836", "0.610338", "0.6071462", "0.60339624", "0.60286355", "0.6027614", "0.5969899", "0.5967955", "0.594652", "0.59414846", "0.5934022...
0.84371173
0
Generate a random string on specific length.
def random_string(samples: str = _random_string_pool, length: int = 12) -> str: return "".join(random.choices(_random_string_pool, k=length)) # noqa: S311
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _generate_random_string(length: int):\n\tall_chars = string.ascii_letters + string.digits\n\treturn ''.join(random.choices(all_chars, k=length))", "def generate_random_string(length):\r\n return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(length))", "def generate_random_...
[ "0.89231753", "0.87974477", "0.87134033", "0.8703507", "0.8668167", "0.8653243", "0.86341083", "0.86110103", "0.8591493", "0.85659665", "0.85629684", "0.85590506", "0.85194975", "0.8511636", "0.844339", "0.84425306", "0.84054554", "0.8402708", "0.83878636", "0.83792204", "0.8...
0.80271244
51
Append a single point to the curve
def append( self, pos=None, color=None, **arguments ): def merge( main, partials, default ): if main is not None: return main result = [] for a,b in zip(partials, default): if a is None: result.append( b ) el...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def appendPoint(self, point):\n self.points.append(point)", "def append_point(self, point):\n self._points.append(point)", "def add_point(self, pt):\n self.points.append(pt)", "def addPoint(self, point):\n self.points.append(point)", "def add(self, point):\n self.points.a...
[ "0.78056544", "0.77534753", "0.75914943", "0.75672245", "0.7541647", "0.74614555", "0.7434237", "0.73218954", "0.72400004", "0.71955955", "0.71862245", "0.705019", "0.70490164", "0.7015477", "0.7014074", "0.7014074", "0.69078493", "0.6891381", "0.685261", "0.67410517", "0.673...
0.0
-1
Takes as input a state and action, and predicts the next state
def _dynamics_func(self, state, action, reuse=False): ### PROBLEM 1 ### YOUR CODE HERE # raise NotImplementedError norm_state = utils.normalize(state, self._init_dataset.state_mean, self._init_dataset.state_std) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def predict(self, state, action):\n assert np.shape(state) == (self._state_dim,)\n assert np.shape(action) == (self._action_dim,)\n\n ### PROBLEM 1\n ### YOUR CODE HERE\n # raise NotImplementedError\n next_state_pred = self._sess.run(self._next_state_pred,\n ...
[ "0.83804655", "0.7728077", "0.76022506", "0.7490477", "0.74095577", "0.72728676", "0.7270169", "0.7264278", "0.7235597", "0.7215788", "0.72067064", "0.720471", "0.7171588", "0.71460575", "0.71282744", "0.70909417", "0.70790106", "0.7070653", "0.70435065", "0.7041552", "0.7034...
0.0
-1
Performs one step of gradient descent
def train_step(self, states, actions, next_states, reward=0): ### PROBLEM 1 ### YOUR CODE HERE # raise NotImplementedError _, loss, _, _ = self._sess.run([self._optimizer, self._loss, self._reward_optimizer, self._reward_loss], feed_dict={self._stat...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_gradient_descent(data,theta,alpha,num_iters):\n population = data[:,0]\n prices = data[:,1]\n x = ones(shape=(len(population),2)) #add ones for theta0 \n x[:,1] = population\n x = transpose(x)\n error_history = zeros(shape=(num_iters,1))\n \n for i in range(num_iters):\n pred...
[ "0.75806767", "0.7295591", "0.7252766", "0.72407925", "0.71839017", "0.7174737", "0.7163976", "0.7146116", "0.7144228", "0.7138368", "0.7132506", "0.7102694", "0.70997876", "0.7088843", "0.7083667", "0.70813483", "0.70410717", "0.7030431", "0.70208067", "0.7013018", "0.701238...
0.0
-1
Predicts the next state given the current state and action
def predict(self, state, action): assert np.shape(state) == (self._state_dim,) assert np.shape(action) == (self._action_dim,) ### PROBLEM 1 ### YOUR CODE HERE # raise NotImplementedError next_state_pred = self._sess.run(self._next_state_pred, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_next_state(self, state, action):\n pass", "def predict_fn(future_action, state):\n model = get_model()\n rewards = model((state, future_action))\n return {\"reward\": rewards}", "def next_state(self, action):\n self.state = self.states[action][self.state]", "def step(self, action):...
[ "0.7627845", "0.76060283", "0.7539147", "0.74652827", "0.7458206", "0.7403397", "0.7386876", "0.73549384", "0.7308754", "0.72552", "0.7239204", "0.7226851", "0.7147186", "0.71455544", "0.70820785", "0.70786005", "0.707099", "0.7013757", "0.69988763", "0.6998862", "0.69899535"...
0.78688645
0