Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Given the code snippet: <|code_start|> def test_concept_eq(lattice): assert lattice[5]._eq(lattice[5]) assert not lattice[1]._eq(lattice[7]) def test_concept_eq_neighors(lattice): c = lattice[7] mock_concept = functools.partial(lattices.Concept, c.lattice, c._extent, c._intent) assert not c._eq(m...
'concepts, expected',
Predict the next line for this snippet: <|code_start|> __all__ = ['PythonLiteral'] def load_file(file) -> SerializedArgs: python_source = file.read() args = ast.literal_eval(python_source) assert args is not None assert isinstance(args, dict) objects = args['objects'] properties = args['prop...
if _serialized is None:
Given the following code snippet before the placeholder: <|code_start|> __all__ = ['PythonLiteral'] def load_file(file) -> SerializedArgs: python_source = file.read() args = ast.literal_eval(python_source) assert args is not None <|code_end|> , predict the next line using imports from the current file: ...
assert isinstance(args, dict)
Given the code snippet: <|code_start|> __all__ = ['WikiTable'] def dump_file(file, objects, properties, bools, *, _serialized=None): write = functools.partial(print, file=file) write('{| class="featuresystem"') write('!') write('!{}'.format('!!'.join(properties))) wp = list(map(len, properties))...
write('|-')
Predict the next line after this snippet: <|code_start|> __all__ = ['iter_cxt_lines', 'Cxt'] SYMBOLS = {False: '.', True: 'X'} def iter_cxt_lines(objects, properties, bools, *, symbols: typing.Mapping[bool, str] = SYMBOLS): assert len(objects) == len(bools) assert {len(properties)} == set...
yield f'{len(properties):d}'
Continue the code snippet: <|code_start|> @pytest.fixture(scope='module') def relation(): xname = 'Condition' yname = 'Symbol' xmembers = 'TT', 'TF', 'FT', 'FF' ymembers = '->', '<-' xbools = [(True, False, True, True), (True, True, False, True)] return matrices.Relation(xname, yname, xmembers...
def test_prime_infimum(relation):
Given snippet: <|code_start|># -*- coding: utf-8 -*- class TestPhonecallsSuperBackup(unittest.TestCase): def setUp(self): self._test_file = os.path.join( os.path.dirname(os.path.abspath(__file__)), 'data', 'calls_superbackup.xml') argv = "-s -f " + self._test_file ...
)
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- class TestGPX(unittest.TestCase): def test_google(self): sample = os.path.join( <|code_end|> with the help of current file imports: import os import unittest from memacs.gpx import GPX and context from other files: # Path...
os.path.dirname(os.path.abspath(__file__)), 'data', 'sample.gpx'
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- # Time-stamp: <2012-09-06 22:02:48 armin> class TestPhonecallsMemacs(unittest.TestCase): def setUp(self): self._test_file = os.path.join( os.path.dirname(os.path.abspath(__file__)), 'data', 'calls.xml' <|code_end|> . Use curre...
)
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- # Time-stamp: <2013-04-04 16:18:07 vk> PROG_VERSION_NUMBER = "0.0" PROG_VERSION_DATE = "2018-07-14" PROG_SHORT_DESCRIPTION = "Memacs for firefox url history " PROG_TAG = "firefox" PROG_DESCRIPTION = """ This class will parse firefox history file (places...
)
Next line prediction: <|code_start|># -*- coding: utf-8 -*- # Time-stamp: <2018-08-25 14:16:04 vk> class TestFoo(unittest.TestCase): def setUp(self): pass def test_all(self): argv = "-s" memacs = Foo(argv=argv.split()) # or when in append mode: # memacs = Foo(argv=a...
data[1],
Continue the code snippet: <|code_start|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Time-stamp: <2013-04-04 16:19:39 vk> PROG_VERSION_NUMBER = "0.1" PROG_VERSION_DATE = "2012-03-10" PROG_SHORT_DESCRIPTION = "Memacs for photos (exif)" PROG_TAG = "photos" PROG_DESCRIPTION = """ This memacs module will walk throu...
If a photo is found, it will get a timestamp from the exif information.
Here is a snippet: <|code_start|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- PROG_VERSION_NUMBER = "0.1" PROG_VERSION_DATE = "2017-02-24" PROG_SHORT_DESCRIPTION = "Memacs for battery" PROG_TAG = "battery" COPYRIGHT_YEAR = "2017" COPYRIGHT_AUTHORS = """Manuel Koell <mankoell@gmail.com>""" def main(): memacs...
copyright_authors=COPYRIGHT_AUTHORS
Given snippet: <|code_start|> sample config: [memacs-example] <-- "memacs-example" has to be CONFIG_PARSER_NAME foo = 0 bar = 1 """ # set CONFIG_PARSER_NAME only, when you want to have a config file # otherwise you can comment it out # CONFIG_PARSER_NAME="memacs-example" COPYRIGHT_YEAR = "2011-2013" COPYRIGH...
if __name__ == "__main__":
Next line prediction: <|code_start|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Time-stamp: <2013-04-04 16:18:07 vk> PROG_VERSION_NUMBER = "0.1" PROG_VERSION_DATE = "2013-09-01" PROG_SHORT_DESCRIPTION = "Memacs for Twitter " PROG_TAG = "mytag" PROG_DESCRIPTION = """ This Memacs module will process your Twitter t...
OAUTH_TOKEN =
Next line prediction: <|code_start|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Time-stamp: <2013-04-04 16:18:40 vk> PROG_VERSION_NUMBER = "0.1" PROG_VERSION_DATE = "2011-12-20" PROG_SHORT_DESCRIPTION = "Memacs for git files " PROG_TAG = "git" PROG_DESCRIPTION = """ This class will parse files from git rev-parse...
$ git rev-list --all --pretty=raw > /path/to/input file
Given snippet: <|code_start|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Time-stamp: <2014-12-13 13:39:15 vk> PROG_VERSION_NUMBER = "0.2" PROG_VERSION_DATE = "2014-12-13" PROG_SHORT_DESCRIPTION = "Memacs for sms" PROG_TAG = "sms" PROG_DESCRIPTION = """ This Memacs module will parse output of sms xml backup files...
def main():
Based on the snippet: <|code_start|> argv.append("-f") argv.append(example1) argv.append("--fieldnames") argv.append("date,text,value,currency,") argv.append("--timestamp-field") argv.append("date") argv.append("--timestamp-format") argv.append("%d.%m.%Y") ...
argv.append("|")
Continue the code snippet: <|code_start|> def test_false_appending(self): try: memacs = RssMemacs(argv=self.argv.split()) memacs.test_get_entries() except Exception: pass def test_all(self): memacs = RssMemacs(argv=self.argv.split()) data = me...
)
Next line prediction: <|code_start|>This Memacs module will parse output of phonecalls xml backup files sample xml file: <?xml version='1.0' encoding='UTF-8' standalone='yes' ?> <calls count="8"> <call number="+43691234123" duration="59" date="1312563906092" type="1" /> <call number="06612341234" duration="22" dat...
copyright_year=COPYRIGHT_YEAR,
Here is a snippet: <|code_start|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Time-stamp: <2013-04-04 16:20:01 vk> PROG_VERSION_NUMBER = "0.1" PROG_VERSION_DATE = "2011-12-27" PROG_SHORT_DESCRIPTION = "Memacs for svn" PROG_TAG = "svn" PROG_DESCRIPTION = """ This Memacs module will parse output of svn log --xml s...
</log>
Here is a snippet: <|code_start|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- CONFIG_PARSER_NAME="memacs-lastfm" PROG_VERSION_NUMBER = "0.1" PROG_VERSION_DATE = "2017-02-24" PROG_SHORT_DESCRIPTION = "Memacs for lastfm" PROG_TAG = "lastfm" COPYRIGHT_YEAR = "2017" COPYRIGHT_AUTHORS = """Manuel Koell <mankoell@gmai...
use_config_parser_name=CONFIG_PARSER_NAME
Using the snippet: <|code_start|>sample xml file: <?xml version='1.0' encoding='UTF-8' standalone='yes' ?> <calls count="8"> <call number="+43691234123" duration="59" date="1312563906092" type="1" /> <call number="06612341234" duration="22" date="1312541215834" type="2" /> <call number="-1" duration="382" date="1...
copyright_authors=COPYRIGHT_AUTHORS
Given the code snippet: <|code_start|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- PROG_VERSION_NUMBER = "0.1" PROG_VERSION_DATE = "2017-03-02" PROG_SHORT_DESCRIPTION = "Memacs for GPX files" PROG_TAG = "gps" COPYRIGHT_YEAR = "2017" <|code_end|> , generate the next line using the imports in this file: from memacs...
COPYRIGHT_AUTHORS = """Manuel Koell <mankoell@gmail.com>"""
Continue the code snippet: <|code_start|> self.assertTrue( data[16].endswith(':41> group-5 (r2): 5.tex') ) self.assertEqual( data[17], " :PROPERTIES:") self.assertEqual( data[18], " :REVISION: 2") self.assertE...
" :ID: 9b7d570e2dc4fb3a009461714358c35cbe24a8fd")
Given the code snippet: <|code_start|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Time-stamp: <2015-04-30 17:12:02 vs> PROG_VERSION_NUMBER = "0.1" PROG_VERSION_DATE = "2015-03-08" PROG_SHORT_DESCRIPTION = "Memacs for Mu Mails" PROG_TAG = "emails:mumail" PROG_DESCRIPTION = """This memacs module will connect mu ma...
copyright_authors=COPYRIGHT_AUTHORS,
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- # Time-stamp: <2013-10-03 15:18:07 br> PROG_VERSION_NUMBER = "0.0" PROG_VERSION_DATE = "2018-10-02" PROG_SHORT_DESCRIPTION = "Memacs for chrome url history " PROG_TAG = "chrome" PROG_DESCRIPTION = """ This class will parse ...
memacs.handle_main()
Here is a snippet: <|code_start|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- PROG_VERSION_NUMBER = "0.1" PROG_VERSION_DATE = "2017-02-28" PROG_SHORT_DESCRIPTION = "Memacs for whatsapp" PROG_TAG = "whatsapp" COPYRIGHT_YEAR = "2017" COPYRIGHT_AUTHORS = """Manuel Koell <mankoell@gmail.com>""" def main(): memac...
)
Given the code snippet: <|code_start|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Time-stamp: <2013-04-04 16:19:47 vk> PROG_VERSION_NUMBER = "0.1" PROG_VERSION_DATE = "2011-12-27" PROG_SHORT_DESCRIPTION = "Memacs for rss feeds" PROG_TAG = "rss" PROG_DESCRIPTION = """ This Memacs module will parse rss files. rss...
: :PROPERTIES:
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- # Time-stamp: <2019-11-06 15:24:56 vk> class TestOrgProperties(unittest.TestCase): def test_properties_default_ctor(self): p = OrgProperties("hashing data 1235") properties = str(p).splitlines() self.assertEqual(properties[0...
self.assertEqual(properties[1], " :CREATED: <1970-01-0" + \
Next line prediction: <|code_start|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Time-stamp: <2013-09-12 09:11 igb> PROG_VERSION_NUMBER = "0.1" PROG_VERSION_DATE = "2012-03-07" PROG_SHORT_DESCRIPTION = "Memacs for sms" <|code_end|> . Use current file imports: (from memacs.sms_superbackup import SmsSuperBackupMem...
PROG_TAG = "sms"
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- # Time-stamp: <2018-09-22 13:57:41 vk> class TestWhatsApp(unittest.TestCase): def setUp(self): msgstore = os.path.join( os.path.dirname(os.path.abspath(__file__)), 'data', 'msgstore.db' ) self.argv = [] self.a...
self.argv.append('{text}')
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Time-stamp: <2013-04-04 16:18:15 vk> PROG_VERSION_NUMBER = "0.1" PROG_VERSION_DATE = "2012-02-24" PROG_SHORT_DESCRIPTION = "Memacs for csv files" PROG_TAG = "csv" PROG_DESCRIPTION = """ This Memacs ...
prog_version=PROG_VERSION_NUMBER,
Using the snippet: <|code_start|># -*- coding: utf-8 -*- # Time-stamp: <2012-03-09 15:36:52 armin> class TestSmsMemacs(unittest.TestCase): def setUp(self): self._test_file = os.path.join( os.path.dirname(os.path.abspath(__file__)), 'data', 'smsxml.txt' ) argv = "-s -f " + se...
self._assertSMSLog(i, data[i*6:(i+1)*6])
Using the snippet: <|code_start|> names = map(lambda model: model.name, models) assert names == [ "CodeISO", "chGeoId10", "MultilingualText09", "OeREBKRM09", "OeREBKRM09vs", "OeREBKRM09trsfr"] assert models[0].version == "20060808" assert models[0].uri == "http://www.kogis.ch" def test_detect_m...
assert "IMPORTS RoadsExdm2ben" in loader.gen_lookup_ili()
Predict the next line for this snippet: <|code_start|> ic, iy, ix = brain.outshape[-3:] if any((iy % self.fdim, ix % self.fdim)): raise RuntimeError( "Incompatible shapes: {} % {}".format((ix, iy), self.fdim) ) LayerBase.connect(self, brain) self.ou...
self.depth = 0
Given the following code snippet before the placeholder: <|code_start|> return self.output def backpropagate(self, delta): return self.op.backward(delta, self.filter) @property def outshape(self): return self.output.shape[-3:] def __str__(self): return "Pool-{}x{}".form...
raise RuntimeError(
Predict the next line for this snippet: <|code_start|> raise RuntimeError( "Incompatible shapes: {} % {}".format((ix, iy), self.fdim) ) LayerBase.connect(self, brain) self.output = zX(ic, iy // self.fdim, ix // self.fdim) def feedforward(self, questions): ...
self.inshape = None
Next line prediction: <|code_start|> def __init__(self, nfilters, filterx=3, filtery=3, compiled=True, **kw): super().__init__(compiled=compiled, **kw) self.nfilters = nfilters self.fx = filterx self.fy = filtery self.depth = 0 self.stride = 1 self.inshape = No...
self.output = self.activation.forward(self.op.forward(X, self.weights, "valid"))
Next line prediction: <|code_start|> class PoolLayer(NoParamMixin, LayerBase): def __init__(self, filter_size, compiled=True): LayerBase.__init__(self, activation="linear", trainable=False) if compiled: else: self.fdim = filter_size self.filter = None self.op = Max...
)
Predict the next line after this snippet: <|code_start|> class PoolLayer(NoParamMixin, LayerBase): def __init__(self, filter_size, compiled=True): LayerBase.__init__(self, activation="linear", trainable=False) if compiled: <|code_end|> using the current file's imports: import numpy as np from ....
else:
Using the snippet: <|code_start|> class DirectFeedbackAlignment(Backpropagation): def __init__(self, layerstack, cost, optimizer, name="", **kw): super().__init__(layerstack, cost, optimizer, name, **kw) self.backwards_weights = np.concatenate( [white(self.outshape[0], np.prod(layer.o...
num_deltas = np.prod(layer.outshape)
Given the code snippet: <|code_start|> class DirectFeedbackAlignment(Backpropagation): def __init__(self, layerstack, cost, optimizer, name="", **kw): super().__init__(layerstack, cost, optimizer, name, **kw) self.backwards_weights = np.concatenate( [white(self.outshape[0], np.prod(la...
all_deltas = error @ self.backwards_weights # [m x net_out] [net_out x [layer_outs]] = [m x [layer_outs]]
Predict the next line for this snippet: <|code_start|> class DenseOp: @staticmethod def forward(X, W, b=None): <|code_end|> with the help of current file imports: from ._llops import dense_forward from brainforge.util.typing import zX and context from other files: # Path: brainforge/llatomic/_llops.py # @...
if b is None:
Here is a snippet: <|code_start|> time, batch, indim = X.shape Z = np.zeros((time, batch, indim+outdim)) O = np.zeros((time, batch, outdim)) T = np.zeros((time, 6, batch, outdim)) # C[0], Ca[1], cand[2], f[3], i[4], o[5] for t in range(time): Z[t] = np.concatenate((X[t], O[t-1]), axis=-1) ...
C, Ca, cand, f, i, o = cache[0], cache[1], cache[2], cache[3], cache[4], cache[5]
Here is a snippet: <|code_start|>s1 = scalX(1.) s2 = scalX(2.) class CostFunction: def __call__(self, outputs, targets): raise NotImplementedError def __str__(self): return self.__class__.__name__ @staticmethod def derivative(outputs, targets): return outputs - targets cla...
return -(targets * np.log(outputs)).sum()
Given the code snippet: <|code_start|>arg = np.arange(len(rX)) np.random.shuffle(arg) targ, varg = arg[:100], arg[100:] targ.sort() varg.sort() tX, tY = rX[targ], rY[targ] vX, vY = rX[varg], rY[varg] tX += np.random.randn(*tX.shape) / np.sqrt(tX.size*0.25) net = Backpropagation([Dense(120, activation="tanh"), ...
batchno = 1
Predict the next line for this snippet: <|code_start|> rX = np.linspace(-6., 6., 200)[:, None] rY = np.sin(rX) arg = np.arange(len(rX)) np.random.shuffle(arg) targ, varg = arg[:100], arg[100:] targ.sort() varg.sort() tX, tY = rX[targ], rY[targ] vX, vY = rX[varg], rY[varg] tX += np.random.randn(*tX.shape) / np.sqrt(t...
vobj, = plt.plot(vX, vpred, "ro", markersize=3, alpha=0.5, label="Validation pred")
Next line prediction: <|code_start|> deltaC *= f[t] deltaZ[t] = np.dot(dgates[t], W.T) E[t-1] += deltaZ[t, :, indim:] if t else s0 nablaW = np.matmul(Z.transpose(0, 2, 1), dgates).sum(axis=0) nablab = np.sum(dgates, axis=(0, 1)) deltaX = deltaZ[:, :, :indim] ...
E[t] += delta
Predict the next line for this snippet: <|code_start|> bwCa = np.atleast_2d(self.actfn.backward(Ca)) deltaC = zX_like(O[-1]) deltaZ = zX_like(Z) dgates = zX(time, batch, outdim*4) for t in range(time-1, -1, -1): deltaC += E[t] * o[t] * bwCa[t] dcand = de...
indim = zdim - outdim
Here is a snippet: <|code_start|> dgates = zX(time, batch, outdim*4) for t in range(time-1, -1, -1): deltaC += E[t] * o[t] * bwCa[t] dcand = deltaC * i[t] df = deltaC * (C[t-1] if t else s0) di = deltaC * cand[t] do = Ca[t] * E[t] ...
bwgates[:, :, -outdim:] = self.actfn.backward(bwgates[:, :, -outdim:])
Continue the code snippet: <|code_start|> cand[t] = p[:, :outdim] f[t] = p[:, outdim:2*outdim] i[t] = p[:, 2*outdim:3*outdim] o[t] = p[:, 3*outdim:] # cand[t], f[t], i[t], o[t] = np.split(p, 4, axis=1) C[t] = C[t-1] * f[t] + cand[t] * i[t] ...
deltaC += E[t] * o[t] * bwCa[t]
Given snippet: <|code_start|> return J class SoftMax(ActivationFunction): type = "softmax" def __init__(self, temperature=1.): if temperature != 1.: self.temperature = scalX(temperature) self.__call__ = self.tn def tn(self, Z): return self.t1(Z / self.temp...
return A * (A[..., None] - I[None, ...])[:, idx, idy]
Predict the next line for this snippet: <|code_start|> return J class SoftMax(ActivationFunction): type = "softmax" def __init__(self, temperature=1.): if temperature != 1.: self.temperature = scalX(temperature) self.__call__ = self.tn def tn(self, Z): ret...
return A * (A[..., None] - I[None, ...])[:, idx, idy]
Here is a snippet: <|code_start|> class Linear(ActivationFunction): type = "linear" def forward(self, Z) -> np.ndarray: return Z def backward(self, Z) -> np.ndarray: return s1 class ReLU(ActivationFunction): type = "relu" def forward(self, Z) -> np.ndarray: return ...
def forward(self, Z: np.ndarray) -> np.ndarray:
Continue the code snippet: <|code_start|> class HillClimbing(AgentBase): def __init__(self, network, nactions, agentconfig=None, **kw): super().__init__(network, agentconfig, **kw) self.rewards = 0 self.bestreward = 0 def reset(self): self.rewards = 0 def sample(self, st...
if self.rewards > self.bestreward:
Given the code snippet: <|code_start|> self.decay = decay def optimize(self, W, gW, m): nabla = gW / m self.memory *= self.decay self.memory += (1. - self.decay) * (nabla ** 2.) updates = (self.eta * nabla) / np.sqrt(self.memory + self.epsilon) return W - updates ...
update = (eta * self.velocity) / np.sqrt(self.memory + self.epsilon)
Here is a snippet: <|code_start|> def ctx1(*arrays): return np.concatenate(arrays, axis=1) def scalX(scalar, dtype=floatX): return np.asscalar(np.array([scalar], dtype=dtype)) def zX(*dims, dtype=floatX): return np.zeros(dims, dtype=dtype) def zX_like(array, dtype=floatX): return zX(*array.shape...
return np.random.randn(fanin, fanout) * np.sqrt(2. / float(fanin + fanout))
Continue the code snippet: <|code_start|> class LocalCorrelationAligment(Backpropagation): def backpropagate(self, error): m = len(error) self.layers[-1].backpropagate(error) all_deltas = error @ self.backwards_weights # [m x net_out] [net_out x [layer_outs]] = [m x [layer_outs]] ...
for layer in self.trainable_layers[1:-1]:
Given snippet: <|code_start|> def _sanitize_configpath(): cfgpath = "~/.brainforgerc" if not exists(cfgpath): cfgpath = "~/.brainforgerc.txt" if not exists(cfgpath): cfgpath = None <|code_end|> , continue by predicting the next line. Consider current file imports: import sys from...
return cfgpath
Given snippet: <|code_start|> np.random.seed(1337) ops = { "sigmoid": (NpSigm(), NbSigm()), "tanh": (NpTanh(), NbTanh()), "relu": (NpReLU(), NbReLU()) } class TestActivationFunctions(unittest.TestCase): def _run_function_test(self, func): npop, nbop = ops[func] npO = npop.forward(...
def test_tanh(self):
Given snippet: <|code_start|> @nb.jit(nopython=True) def recurrent_forward_relu(X, W, b): outdim = W.shape[-1] time, batch, indim = X.shape O = np.zeros((time, batch, outdim)) for t in range(time): Z = np.concatenate((X[t], O[t-1]), axis=-1) preact = np.dot(Z, W) + b O[t] = relu...
nablaW = np.zeros_like(W)
Continue the code snippet: <|code_start|> @nb.jit(nopython=True) def recurrent_forward_relu(X, W, b): outdim = W.shape[-1] time, batch, indim = X.shape O = np.zeros((time, batch, outdim)) for t in range(time): Z = np.concatenate((X[t], O[t-1]), axis=-1) preact = np.dot(Z, W) + b ...
nablaW = np.zeros_like(W)
Predict the next line for this snippet: <|code_start|> def __call__(self): raise NotImplementedError @abc.abstractmethod def derivative(self, eta, m): raise NotImplementedError @abc.abstractmethod def __str__(self): raise NotImplementedError class L1Norm(Regularizer): ...
return (s1 - ((eta * self.lmbd) / m)) * self.layer.get_weights().sum()
Next line prediction: <|code_start|> im, ic, iy, ix = A.shape nf, fc, fy, fx = F.shape # fx, fy, fc, nf = F.shape oy, ox = iy - fy + 1, ix - fx + 1 rfields = _reshape_receptive_fields(A, F) # output = np.zeros((im, oy*ox, nf), dtype=nbfloatX) Frsh = F.reshape(nf, fx * fy * fc) output = n...
filt[m, c, sy:sy + fdim, sx:sx + fdim] += filterfield
Given the code snippet: <|code_start|> @staticmethod def full(A, F): nf, fc, fy, fx = F.shape py, px = fy - 1, fx - 1 pA = np.pad(A, pad_width=((0, 0), (0, 0), (py, py), (px, px)), mode="constant", constant_values=0.) return ConvolutionOp.valid(pA, F) @sta...
def outshape(inshape, fshape, mode="valid"):
Given the following code snippet before the placeholder: <|code_start|> s0 = scalX(0., floatX) s1 = scalX(1., floatX) s2 = scalX(2., floatX) finfout = "{t}({t})".format(t=nbfloatX) jitsig = "{t}({t})".format(t=Xd(1)) @nb.vectorize(finfout, nopython=True) def sigmoid(Z): return s1 / (s1 + np.exp(-Z)) @nb.vecto...
def tanh(Z):
Next line prediction: <|code_start|> s0 = scalX(0., floatX) s1 = scalX(1., floatX) s2 = scalX(2., floatX) finfout = "{t}({t})".format(t=nbfloatX) jitsig = "{t}({t})".format(t=Xd(1)) @nb.vectorize(finfout, nopython=True) def sigmoid(Z): <|code_end|> . Use current file imports: (import numpy as np import numba as nb...
return s1 / (s1 + np.exp(-Z))
Here is a snippet: <|code_start|> s0 = scalX(0., floatX) s1 = scalX(1., floatX) s2 = scalX(2., floatX) finfout = "{t}({t})".format(t=nbfloatX) jitsig = "{t}({t})".format(t=Xd(1)) @nb.vectorize(finfout, nopython=True) def sigmoid(Z): return s1 / (s1 + np.exp(-Z)) @nb.vectorize(finfout, nopython=True) def sigmo...
@nb.vectorize(finfout, nopython=True)
Next line prediction: <|code_start|> s0 = scalX(0., floatX) s1 = scalX(1., floatX) s2 = scalX(2., floatX) finfout = "{t}({t})".format(t=nbfloatX) jitsig = "{t}({t})".format(t=Xd(1)) <|code_end|> . Use current file imports: (import numpy as np import numba as nb from ._llutil import floatX, Xd, nbfloatX from brainf...
@nb.vectorize(finfout, nopython=True)
Based on the snippet: <|code_start|> class AgentConfig: def __init__(self, batch_size=128, discount_factor=0.99, knowledge_transfer_rate=0.1, epsilon_greedy_rate=0.9, epsilon_decay=1.0, epsilon_min=0.01, replay_m...
@property
Given the following code snippet before the placeholder: <|code_start|> class AgentConfig: def __init__(self, batch_size=128, discount_factor=0.99, knowledge_transfer_rate=0.1, epsilon_greedy_rate=0.9, epsilon_decay=1.0, epsilon_...
self.epsilon = self.epsilon_min
Given snippet: <|code_start|> class LLActivation(abc.ABC): type = "" def __init__(self): self.llact, self.llactp = { "sigmoid": (sigmoid, sigmoid_p), "tanh": (tanh, tanh_p), "relu": (relu, relu_p) }[self.type] def forward(self, X): return self....
type = "sigmoid"
Given the code snippet: <|code_start|> class LLActivation(abc.ABC): type = "" def __init__(self): self.llact, self.llactp = { "sigmoid": (sigmoid, sigmoid_p), "tanh": (tanh, tanh_p), "relu": (relu, relu_p) }[self.type] def forward(self, X): ret...
type = "sqrt"
Given the code snippet: <|code_start|> class LLActivation(abc.ABC): type = "" def __init__(self): <|code_end|> , generate the next line using the imports in this file: import abc from ._llactivation import ( sigmoid, sigmoid_p, tanh, tanh_p, relu, relu_p, # softmax, softmax_p, ) and context...
self.llact, self.llactp = {
Continue the code snippet: <|code_start|> class LLActivation(abc.ABC): type = "" def __init__(self): self.llact, self.llactp = { "sigmoid": (sigmoid, sigmoid_p), "tanh": (tanh, tanh_p), "relu": (relu, relu_p) }[self.type] def forward(self, X): ...
type = "sqrt"
Using the snippet: <|code_start|> class LLActivation(abc.ABC): type = "" def __init__(self): self.llact, self.llactp = { "sigmoid": (sigmoid, sigmoid_p), "tanh": (tanh, tanh_p), "relu": (relu, relu_p) <|code_end|> , determine the next line of code. You have imports...
}[self.type]
Next line prediction: <|code_start|> class LayerStack(Model): def __init__(self, input_shape, layers=()): super().__init__(input_shape) self.layers = [] self.architecture = [] self.learning = False self._iterme = None self._add_input_layer(input_shape) for...
input_shape = (input_shape,)
Continue the code snippet: <|code_start|> class LayerStack(Model): def __init__(self, input_shape, layers=()): super().__init__(input_shape) self.layers = [] self.architecture = [] self.learning = False self._iterme = None <|code_end|> . Use current file imports: import ...
self._add_input_layer(input_shape)
Given snippet: <|code_start|> class DNI: def __init__(self, bpropnet, synth): self.bpropnet = bpropnet self.synth = synth self._predictor = None def predictor_coro(self): prediction = None delta_backwards = None while 1: inputs = yield prediction, d...
next(self._predictor)
Using the snippet: <|code_start|> class DNI: def __init__(self, bpropnet, synth): self.bpropnet = bpropnet self.synth = synth self._predictor = None <|code_end|> , determine the next line of code. You have imports: from brainforge.learner import Backpropagation from brainforge.layers imp...
def predictor_coro(self):
Given the code snippet: <|code_start|> class DNI: def __init__(self, bpropnet, synth): self.bpropnet = bpropnet self.synth = synth self._predictor = None def predictor_coro(self): prediction = None delta_backwards = None <|code_end|> , generate the next line using the ...
while 1:
Based on the snippet: <|code_start|> class DNI: def __init__(self, bpropnet, synth): self.bpropnet = bpropnet self.synth = synth self._predictor = None def predictor_coro(self): prediction = None delta_backwards = None while 1: inputs = yield predic...
synthesizer_delta = self.synth.cost.derivative(
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals DEFAULT_DELIMITER = ',' @python_2_unicode_compatible class SelectMultipleField(six.with_metaclass(models.SubfieldBase, <|code_end|> . Use current file imports: from django.core import exceptions, validators f...
models.Field)):
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals DEFAULT_DELIMITER = ',' @python_2_unicode_compatible <|code_end|> with the help of current file imports: from django.core import exceptions, validators from django.db import models from django.u...
class SelectMultipleField(six.with_metaclass(models.SubfieldBase,
Here is a snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals DEFAULT_DELIMITER = ',' @python_2_unicode_compatible <|code_end|> . Write the next line using the current file imports: from django.core import exceptions, validators from django.db import models from django.utils im...
class SelectMultipleField(six.with_metaclass(models.SubfieldBase,
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class SelectMultipleFieldTestCase(SimpleTestCase): def setUp(self): self.choices = ( ('a', 'Alpha'), ('b', 'Bravo'), ('c', 'Charlie'), ) def test_instan...
def test_has_select_multiple_class(self):
Using the snippet: <|code_start|> class PizzaListView(ListView): queryset = Pizza.objects.order_by('-id') context_object_name = 'pizzas' paginate_by = 10 class PizzaCreateView(CreateView): model = Pizza fields = ['toppings'] success_url = reverse_lazy('pizza:created') class PizzaDetailV...
class PizzaDeleteView(DeleteView):
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class SelectMultipleFormFieldTestCase(SimpleTestCase): def setUp(self): self.choices = tuple([(c, c) for c in string.ascii_letters]) <|code_end|> with the help of current file imports...
self.choices_list = [c[0] for c in self.choices[0:len(self.choices)]]
Based on the snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class SelectMultipleFormFieldTestCase(SimpleTestCase): def setUp(self): self.choices = tuple([(c, c) for c in string.ascii_letters]) self.choices_list = [c[0] for c in self.choices[0:len(self.ch...
def test_widget_class(self):
Next line prediction: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class SelectMultipleFormFieldTestCase(SimpleTestCase): def setUp(self): self.choices = tuple([(c, c) for c in string.ascii_letters]) self.choices_list = [c[0] for c in self.choices[0:len(self.ch...
def test_instantiation(self):
Next line prediction: <|code_start|> urlpatterns = patterns('', # NOQA url(r'^$', ChickenWingsListView.as_view(), name='list'), url(r'^create/$', ChickenWingsCreateView.as_view(), name='create'), url(r'^created/$', TemplateView.as_view( template_name='forthewing/chickenwings_created.html'), name=...
url(r'^update/(?P<pk>[0-9]*)$',
Continue the code snippet: <|code_start|> urlpatterns = patterns('', # NOQA url(r'^$', ChickenWingsListView.as_view(), name='list'), url(r'^create/$', ChickenWingsCreateView.as_view(), name='create'), url(r'^created/$', TemplateView.as_view( template_name='forthewing/chickenwings_created.html'), ...
url(r'^detail/(?P<pk>[0-9]*)$',
Using the snippet: <|code_start|> urlpatterns = patterns('', # NOQA url(r'^$', ChickenWingsListView.as_view(), name='list'), url(r'^create/$', ChickenWingsCreateView.as_view(), name='create'), url(r'^created/$', TemplateView.as_view( template_name='forthewing/chickenwings_created.html'), name='cr...
template_name='forthewing/chickenwings_deleted.html'), name='deleted'),
Here is a snippet: <|code_start|> urlpatterns = patterns('', # NOQA url(r'^$', ChickenWingsListView.as_view(), name='list'), url(r'^create/$', ChickenWingsCreateView.as_view(), name='create'), url(r'^created/$', TemplateView.as_view( template_name='forthewing/chickenwings_created.html'), name='cr...
)
Given snippet: <|code_start|> urlpatterns = patterns('', # NOQA url(r'^$', ChickenWingsListView.as_view(), name='list'), url(r'^create/$', ChickenWingsCreateView.as_view(), name='create'), url(r'^created/$', TemplateView.as_view( template_name='forthewing/chickenwings_created.html'), name='create...
)
Continue the code snippet: <|code_start|> ) self.test_list = ['a', 'b', 'c'] self.test_encoded = 'a,b,c' self.wild_delimiter = 'シ' self.test_encoded_alt = 'aシbシc' def test_decoder(self): decoded = decode_csv_to_list(self.test_encoded) self.assertEqual(decoded,...
def test_encoder(self):
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*- from __future__ import unicode_literals class CodecTestCase(SimpleTestCase): def setUp(self): self.choices = ( <|code_end|> with the help of current file imports: from django.test import SimpleTestCase from select_multiple_...
('a', 'Alpha'),
Given the code snippet: <|code_start|> queryset = ChickenWings.objects.order_by('-id') context_object_name = 'chickenwings' paginate_by = 10 class ChickenWingsCreateView(CreateView): model = ChickenWings fields = ['flavour'] success_url = reverse_lazy('ftw:created') context_object_name = '...
def get_success_url(self):
Predict the next line after this snippet: <|code_start|> urlpatterns = patterns('', # NOQA url(r'^$', PizzaListView.as_view(), name='list'), url(r'^create/$', PizzaCreateView.as_view(), name='create'), url(r'^created/$', TemplateView.as_view( template_name='pizzagigi/pizza_created.html'), name='c...
)