body stringlengths 26 98.2k | body_hash int64 -9,222,864,604,528,158,000 9,221,803,474B | docstring stringlengths 1 16.8k | path stringlengths 5 230 | name stringlengths 1 96 | repository_name stringlengths 7 89 | lang stringclasses 1
value | body_without_docstring stringlengths 20 98.2k |
|---|---|---|---|---|---|---|---|
def get_min_max(ints):
'\n Return a tuple(min, max) out of list of unsorted integers.\n\n Args:\n ints(list): list of integers containing one or more integers\n '
if (not isinstance(ints, list)):
return (None, None)
min_value = None
max_value = None
for (index, value) in enume... | 4,778,962,711,514,575,000 | Return a tuple(min, max) out of list of unsorted integers.
Args:
ints(list): list of integers containing one or more integers | problem_6.py | get_min_max | johangenis/problems_vs_algorithms | python | def get_min_max(ints):
'\n Return a tuple(min, max) out of list of unsorted integers.\n\n Args:\n ints(list): list of integers containing one or more integers\n '
if (not isinstance(ints, list)):
return (None, None)
min_value = None
max_value = None
for (index, value) in enume... |
def dijkstra_iterator(nodes: list[Node], src_id: int, hf=(lambda x: 0.0)):
'\n Internal loop of the Dijkstra algorithm\n as a step by step iterator\n hf is an optional heuristic\n '
visited_nodes = set()
h: list[tuple[(float, Node)]] = []
previous = dict()
distances = defaultdict((lambda... | 2,886,912,168,696,677,400 | Internal loop of the Dijkstra algorithm
as a step by step iterator
hf is an optional heuristic | bidir_dijkstra.py | dijkstra_iterator | colon3ltocard/pythonalgorithms | python | def dijkstra_iterator(nodes: list[Node], src_id: int, hf=(lambda x: 0.0)):
'\n Internal loop of the Dijkstra algorithm\n as a step by step iterator\n hf is an optional heuristic\n '
visited_nodes = set()
h: list[tuple[(float, Node)]] = []
previous = dict()
distances = defaultdict((lambda... |
def dijkstra_forward(nodes: list[Node], src_id: int, dst_id: int, hf=(lambda x: 0.0)) -> list[int]:
"\n 'classical' forward Dijkstra but based on our iterator.\n "
coro = dijkstra_iterator(nodes, src_id, hf=hf)
for ctx in coro:
if (ctx.node is None):
return ([], [])
elif (c... | 8,656,843,063,080,979,000 | 'classical' forward Dijkstra but based on our iterator. | bidir_dijkstra.py | dijkstra_forward | colon3ltocard/pythonalgorithms | python | def dijkstra_forward(nodes: list[Node], src_id: int, dst_id: int, hf=(lambda x: 0.0)) -> list[int]:
"\n \n "
coro = dijkstra_iterator(nodes, src_id, hf=hf)
for ctx in coro:
if (ctx.node is None):
return ([], [])
elif (ctx.node.id == dst_id):
return (ctx.distance... |
def bidir_dijkstra(nodes: list[Node], src_id: int, dst_id: int, hff=(lambda _: 0.0), hfb=(lambda _: 0.0), consistent: bool=True) -> list[int]:
'\n bidirectionnal dijkstra, we search from both start => end\n and end => start using two iterators.\n hff and hfb are optional heuristics\n for respectively th... | -3,832,702,865,269,007,000 | bidirectionnal dijkstra, we search from both start => end
and end => start using two iterators.
hff and hfb are optional heuristics
for respectively the forward and backward iterators
(for later bidir A*) | bidir_dijkstra.py | bidir_dijkstra | colon3ltocard/pythonalgorithms | python | def bidir_dijkstra(nodes: list[Node], src_id: int, dst_id: int, hff=(lambda _: 0.0), hfb=(lambda _: 0.0), consistent: bool=True) -> list[int]:
'\n bidirectionnal dijkstra, we search from both start => end\n and end => start using two iterators.\n hff and hfb are optional heuristics\n for respectively th... |
def make_animated_gif(title: str, g: list[Node], dst_file: str, fs: list[Node], bs: list[Node], shortest: list[Node], draw_edges: bool=True, writer: str='ffmpeg', interval: int=250, blinking_ratio=0.5):
'\n Makes an animated gif out of two sequences of forward (fs) and backward (bs)\n path-finding algorithm. ... | -5,620,099,599,551,044,000 | Makes an animated gif out of two sequences of forward (fs) and backward (bs)
path-finding algorithm. The final shortest path will be blinked. | bidir_dijkstra.py | make_animated_gif | colon3ltocard/pythonalgorithms | python | def make_animated_gif(title: str, g: list[Node], dst_file: str, fs: list[Node], bs: list[Node], shortest: list[Node], draw_edges: bool=True, writer: str='ffmpeg', interval: int=250, blinking_ratio=0.5):
'\n Makes an animated gif out of two sequences of forward (fs) and backward (bs)\n path-finding algorithm. ... |
def update(self, nodes: tuple[(Node, Node, list[Node])]):
'\n Updates the plot with a tuple of nodes (forward, backward, shortest_path)\n '
(f, b, s) = nodes
if (not s):
self._colors[f.id] = 1
self._colors[b.id] = 2
self.ax.scatter.set_array(self._colors)
return... | 5,186,616,441,863,305,000 | Updates the plot with a tuple of nodes (forward, backward, shortest_path) | bidir_dijkstra.py | update | colon3ltocard/pythonalgorithms | python | def update(self, nodes: tuple[(Node, Node, list[Node])]):
'\n \n '
(f, b, s) = nodes
if (not s):
self._colors[f.id] = 1
self._colors[b.id] = 2
self.ax.scatter.set_array(self._colors)
return (self.ax.scatter,)
else:
x = [n.x for n in s]
y = [n... |
def build(self):
'\n Construct the main structure of the network\n '
print('DNN input shape', self.input_shape)
if (K.image_dim_ordering() == 'tf'):
(batch_sz, bands, frames, channels) = self.input_shape
assert (channels >= 1)
channel_axis = 3
freq_axis = 1
... | -1,732,019,826,705,050,000 | Construct the main structure of the network | src/model/sed_ogits.py | build | Vanova/mfom_attribute_detection | python | def build(self):
'\n \n '
print('DNN input shape', self.input_shape)
if (K.image_dim_ordering() == 'tf'):
(batch_sz, bands, frames, channels) = self.input_shape
assert (channels >= 1)
channel_axis = 3
freq_axis = 1
nn_shape = (bands, frames, channels)
... |
def rebuild(self, new_config):
"\n Recompile the model with the new hyper parameters.\n NOTE: network topology is changing according to the 'new_config'\n "
self.config.update(new_config)
(batch_sz, bands, frames, channels) = self.input_shape
self.input_shape = (self.config['batch']... | 7,933,325,750,823,798,000 | Recompile the model with the new hyper parameters.
NOTE: network topology is changing according to the 'new_config' | src/model/sed_ogits.py | rebuild | Vanova/mfom_attribute_detection | python | def rebuild(self, new_config):
"\n Recompile the model with the new hyper parameters.\n NOTE: network topology is changing according to the 'new_config'\n "
self.config.update(new_config)
(batch_sz, bands, frames, channels) = self.input_shape
self.input_shape = (self.config['batch']... |
def chage_optimizer(self, new_config, change_out_unit=False):
'\n Recompile the model with the new loss and optimizer.\n NOTE: network topology is not changing.\n '
if new_config['freeze_wt']:
for layer in self.model.layers[:(- 4)]:
layer.trainable = False
input = se... | 1,734,875,810,475,922,400 | Recompile the model with the new loss and optimizer.
NOTE: network topology is not changing. | src/model/sed_ogits.py | chage_optimizer | Vanova/mfom_attribute_detection | python | def chage_optimizer(self, new_config, change_out_unit=False):
'\n Recompile the model with the new loss and optimizer.\n NOTE: network topology is not changing.\n '
if new_config['freeze_wt']:
for layer in self.model.layers[:(- 4)]:
layer.trainable = False
input = se... |
def _compile_model(self, input, output, params):
'\n Compile network structure with particular loss and optimizer\n '
if (params['loss'] in obj.MFOM_OBJECTIVES):
(_, _, frames, _) = self.input_shape
y_true = Input(shape=(frames, self.nclass), name='y_true')
psi = mfom.UvZMi... | 6,074,246,226,617,041,000 | Compile network structure with particular loss and optimizer | src/model/sed_ogits.py | _compile_model | Vanova/mfom_attribute_detection | python | def _compile_model(self, input, output, params):
'\n \n '
if (params['loss'] in obj.MFOM_OBJECTIVES):
(_, _, frames, _) = self.input_shape
y_true = Input(shape=(frames, self.nclass), name='y_true')
psi = mfom.UvZMisclassification(name='uvz_misclass')([y_true, output])
... |
def test_recompute_optimizer_backward(self):
' test recompute optimizer backward '
(train_prog, startup_prog) = (fluid.Program(), fluid.Program())
(avg_cost, strategy) = self.net(train_prog, startup_prog)
self.set_strategy(strategy, 'recompute')
opt = fluid.optimizer.MomentumOptimizer(learning_rate=... | 5,152,517,799,279,989,000 | test recompute optimizer backward | python/paddle/fluid/tests/unittests/test_fleet_recompute_meta_optimizer.py | test_recompute_optimizer_backward | 0x45f/Paddle | python | def test_recompute_optimizer_backward(self):
' '
(train_prog, startup_prog) = (fluid.Program(), fluid.Program())
(avg_cost, strategy) = self.net(train_prog, startup_prog)
self.set_strategy(strategy, 'recompute')
opt = fluid.optimizer.MomentumOptimizer(learning_rate=0.001, momentum=0.9)
opt = Re... |
def test_recompute_optimizer_backward_gradients(self):
' test recompute optimizer backward + gradients '
(train_prog, startup_prog) = (fluid.Program(), fluid.Program())
(avg_cost, strategy) = self.net(train_prog, startup_prog)
self.set_strategy(strategy, 'recompute')
opt = fluid.optimizer.MomentumOp... | -2,802,897,495,768,435,700 | test recompute optimizer backward + gradients | python/paddle/fluid/tests/unittests/test_fleet_recompute_meta_optimizer.py | test_recompute_optimizer_backward_gradients | 0x45f/Paddle | python | def test_recompute_optimizer_backward_gradients(self):
' '
(train_prog, startup_prog) = (fluid.Program(), fluid.Program())
(avg_cost, strategy) = self.net(train_prog, startup_prog)
self.set_strategy(strategy, 'recompute')
opt = fluid.optimizer.MomentumOptimizer(learning_rate=0.001, momentum=0.9)
... |
def test_recompute_optimizer_backward_optimize(self):
' test recompute optimizer backward + optimize '
(train_prog, startup_prog) = (fluid.Program(), fluid.Program())
(avg_cost, strategy) = self.net(train_prog, startup_prog)
self.set_strategy(strategy, 'recompute')
opt = fluid.optimizer.MomentumOpti... | 7,818,845,906,098,357,000 | test recompute optimizer backward + optimize | python/paddle/fluid/tests/unittests/test_fleet_recompute_meta_optimizer.py | test_recompute_optimizer_backward_optimize | 0x45f/Paddle | python | def test_recompute_optimizer_backward_optimize(self):
' '
(train_prog, startup_prog) = (fluid.Program(), fluid.Program())
(avg_cost, strategy) = self.net(train_prog, startup_prog)
self.set_strategy(strategy, 'recompute')
opt = fluid.optimizer.MomentumOptimizer(learning_rate=0.001, momentum=0.9)
... |
def test_recompute_optimizer_backward(self):
' test recompute optimizer backward '
(train_prog, startup_prog) = (fluid.Program(), fluid.Program())
(avg_cost, strategy) = self.net(train_prog, startup_prog)
self.set_strategy(strategy, 'recompute')
opt = fluid.optimizer.MomentumOptimizer(learning_rate=... | 5,152,517,799,279,989,000 | test recompute optimizer backward | python/paddle/fluid/tests/unittests/test_fleet_recompute_meta_optimizer.py | test_recompute_optimizer_backward | 0x45f/Paddle | python | def test_recompute_optimizer_backward(self):
' '
(train_prog, startup_prog) = (fluid.Program(), fluid.Program())
(avg_cost, strategy) = self.net(train_prog, startup_prog)
self.set_strategy(strategy, 'recompute')
opt = fluid.optimizer.MomentumOptimizer(learning_rate=0.001, momentum=0.9)
opt = Re... |
def test_recompute_optimizer_backward(self):
' test recompute optimizer backward '
(train_prog, startup_prog) = (fluid.Program(), fluid.Program())
(avg_cost, strategy) = self.net(train_prog, startup_prog)
self.set_strategy(strategy, 'recompute')
opt = fluid.optimizer.MomentumOptimizer(learning_rate=... | 5,152,517,799,279,989,000 | test recompute optimizer backward | python/paddle/fluid/tests/unittests/test_fleet_recompute_meta_optimizer.py | test_recompute_optimizer_backward | 0x45f/Paddle | python | def test_recompute_optimizer_backward(self):
' '
(train_prog, startup_prog) = (fluid.Program(), fluid.Program())
(avg_cost, strategy) = self.net(train_prog, startup_prog)
self.set_strategy(strategy, 'recompute')
opt = fluid.optimizer.MomentumOptimizer(learning_rate=0.001, momentum=0.9)
opt = Re... |
def __init__(self, value: AutoMapperNumberInputType) -> None:
'\n Converts the value to a timestamp type in Spark\n\n\n :param value: value\n :param formats: (Optional) formats to use for trying to parse the value otherwise uses Spark defaults\n '
super().__init__()
self.value: A... | 370,410,302,628,395,260 | Converts the value to a timestamp type in Spark
:param value: value
:param formats: (Optional) formats to use for trying to parse the value otherwise uses Spark defaults | spark_auto_mapper/data_types/unix_timestamp.py | __init__ | icanbwell/SparkAutoMapper | python | def __init__(self, value: AutoMapperNumberInputType) -> None:
'\n Converts the value to a timestamp type in Spark\n\n\n :param value: value\n :param formats: (Optional) formats to use for trying to parse the value otherwise uses Spark defaults\n '
super().__init__()
self.value: A... |
def set_login_url(self):
' Sets the LOGIN_URL variable in the suite scope which will\n automatically log into the target Salesforce org.\n\n Typically, this is run during Suite Setup\n '
BuiltIn().set_suite_variable('${LOGIN_URL}', self.org.start_url) | -1,357,690,966,029,153,500 | Sets the LOGIN_URL variable in the suite scope which will
automatically log into the target Salesforce org.
Typically, this is run during Suite Setup | cumulusci/robotframework/CumulusCI.py | set_login_url | jdominiczak/CumulusCI | python | def set_login_url(self):
' Sets the LOGIN_URL variable in the suite scope which will\n automatically log into the target Salesforce org.\n\n Typically, this is run during Suite Setup\n '
BuiltIn().set_suite_variable('${LOGIN_URL}', self.org.start_url) |
def get_org_info(self):
' Returns a dictionary of the org information for the current target\n Salesforce org\n '
return self.org.config | 2,211,106,333,232,215,000 | Returns a dictionary of the org information for the current target
Salesforce org | cumulusci/robotframework/CumulusCI.py | get_org_info | jdominiczak/CumulusCI | python | def get_org_info(self):
' Returns a dictionary of the org information for the current target\n Salesforce org\n '
return self.org.config |
def login_url(self, org=None):
' Returns the login url which will automatically log into the target\n Salesforce org. By default, the org_name passed to the library\n constructor is used but this can be overridden with the org option\n to log into a different org.\n '
if... | 2,138,725,497,225,529,600 | Returns the login url which will automatically log into the target
Salesforce org. By default, the org_name passed to the library
constructor is used but this can be overridden with the org option
to log into a different org. | cumulusci/robotframework/CumulusCI.py | login_url | jdominiczak/CumulusCI | python | def login_url(self, org=None):
' Returns the login url which will automatically log into the target\n Salesforce org. By default, the org_name passed to the library\n constructor is used but this can be overridden with the org option\n to log into a different org.\n '
if... |
def get_namespace_prefix(self, package=None):
' Returns the namespace prefix (including __) for the specified package name.\n (Defaults to project__package__name_managed from the current project config.)\n\n Returns an empty string if the package is not installed as a managed package.\n '
r... | -2,532,857,310,747,178,500 | Returns the namespace prefix (including __) for the specified package name.
(Defaults to project__package__name_managed from the current project config.)
Returns an empty string if the package is not installed as a managed package. | cumulusci/robotframework/CumulusCI.py | get_namespace_prefix | jdominiczak/CumulusCI | python | def get_namespace_prefix(self, package=None):
' Returns the namespace prefix (including __) for the specified package name.\n (Defaults to project__package__name_managed from the current project config.)\n\n Returns an empty string if the package is not installed as a managed package.\n '
r... |
def run_task(self, task_name, **options):
' Runs a named CumulusCI task for the current project with optional\n support for overriding task options via kwargs.\n\n Examples:\n | =Keyword= | =task_name= | =task_options= | =comment= |\n | ... | 2,809,326,719,546,375,000 | Runs a named CumulusCI task for the current project with optional
support for overriding task options via kwargs.
Examples:
| =Keyword= | =task_name= | =task_options= | =comment= |
| Run Task | deploy | | Run deploy with standard options |
| Run Task ... | cumulusci/robotframework/CumulusCI.py | run_task | jdominiczak/CumulusCI | python | def run_task(self, task_name, **options):
' Runs a named CumulusCI task for the current project with optional\n support for overriding task options via kwargs.\n\n Examples:\n | =Keyword= | =task_name= | =task_options= | =comment= |\n | ... |
def run_task_class(self, class_path, **options):
" Runs a CumulusCI task class with task options via kwargs.\n\n Use this keyword to run logic from CumulusCI tasks which have not\n been configured in the project's cumulusci.yml file. This is\n most useful in cases where a test need... | 6,214,255,676,449,666,000 | Runs a CumulusCI task class with task options via kwargs.
Use this keyword to run logic from CumulusCI tasks which have not
been configured in the project's cumulusci.yml file. This is
most useful in cases where a test needs to use task logic for
logic unique to the test and thus not worth making into a named
task fo... | cumulusci/robotframework/CumulusCI.py | run_task_class | jdominiczak/CumulusCI | python | def run_task_class(self, class_path, **options):
" Runs a CumulusCI task class with task options via kwargs.\n\n Use this keyword to run logic from CumulusCI tasks which have not\n been configured in the project's cumulusci.yml file. This is\n most useful in cases where a test need... |
def debug(self):
'Pauses execution and enters the Python debugger.'
set_pdb_trace() | -8,269,812,006,413,925,000 | Pauses execution and enters the Python debugger. | cumulusci/robotframework/CumulusCI.py | debug | jdominiczak/CumulusCI | python | def debug(self):
set_pdb_trace() |
def load_image_from_folder(folder_path, new_size, HE=False, Truc=False, Aug=False):
'loads images in the folder_path and returns a ndarray and threshold the label image'
image_list = []
label_list = []
for image_name in os.listdir(folder_path):
image_original = np.load((folder_path + image_name)... | -2,177,866,537,373,515,800 | loads images in the folder_path and returns a ndarray and threshold the label image | DIPDenoising/image_reading.py | load_image_from_folder | junyuchen245/NM-Img-Denoising-DIP-Keras | python | def load_image_from_folder(folder_path, new_size, HE=False, Truc=False, Aug=False):
image_list = []
label_list = []
for image_name in os.listdir(folder_path):
image_original = np.load((folder_path + image_name))
image_original = image_original['a']
image_ct = image_original[:, 0... |
def load_test_from_folder(folder_path, new_size, HE=False, Truc=False, Aug=False):
'loads images in the folder_path and returns a ndarray and threshold the label image'
image_list = []
for image_name in os.listdir(folder_path):
image_original = np.load((folder_path + image_name))
image_origi... | -3,532,767,422,098,932,700 | loads images in the folder_path and returns a ndarray and threshold the label image | DIPDenoising/image_reading.py | load_test_from_folder | junyuchen245/NM-Img-Denoising-DIP-Keras | python | def load_test_from_folder(folder_path, new_size, HE=False, Truc=False, Aug=False):
image_list = []
for image_name in os.listdir(folder_path):
image_original = np.load((folder_path + image_name))
image_original = image_original['a']
image_ct = image_original[:, 0:len(image_original)]... |
def __init__(__self__, *, s3: pulumi.Input['SigningJobDestinationS3Args']):
"\n :param pulumi.Input['SigningJobDestinationS3Args'] s3: A configuration block describing the S3 Destination object: See S3 Destination below for details.\n "
pulumi.set(__self__, 's3', s3) | 6,355,375,750,964,583,000 | :param pulumi.Input['SigningJobDestinationS3Args'] s3: A configuration block describing the S3 Destination object: See S3 Destination below for details. | sdk/python/pulumi_aws/signer/_inputs.py | __init__ | chivandikwa/pulumi-aws | python | def __init__(__self__, *, s3: pulumi.Input['SigningJobDestinationS3Args']):
"\n \n "
pulumi.set(__self__, 's3', s3) |
@property
@pulumi.getter
def s3(self) -> pulumi.Input['SigningJobDestinationS3Args']:
'\n A configuration block describing the S3 Destination object: See S3 Destination below for details.\n '
return pulumi.get(self, 's3') | 6,717,553,919,461,040,000 | A configuration block describing the S3 Destination object: See S3 Destination below for details. | sdk/python/pulumi_aws/signer/_inputs.py | s3 | chivandikwa/pulumi-aws | python | @property
@pulumi.getter
def s3(self) -> pulumi.Input['SigningJobDestinationS3Args']:
'\n \n '
return pulumi.get(self, 's3') |
def __init__(__self__, *, bucket: pulumi.Input[str], prefix: Optional[pulumi.Input[str]]=None):
'\n :param pulumi.Input[str] bucket: Name of the S3 bucket.\n :param pulumi.Input[str] prefix: An Amazon S3 object key prefix that you can use to limit signed objects keys to begin with the specified prefix... | -8,556,780,313,228,384,000 | :param pulumi.Input[str] bucket: Name of the S3 bucket.
:param pulumi.Input[str] prefix: An Amazon S3 object key prefix that you can use to limit signed objects keys to begin with the specified prefix. | sdk/python/pulumi_aws/signer/_inputs.py | __init__ | chivandikwa/pulumi-aws | python | def __init__(__self__, *, bucket: pulumi.Input[str], prefix: Optional[pulumi.Input[str]]=None):
'\n :param pulumi.Input[str] bucket: Name of the S3 bucket.\n :param pulumi.Input[str] prefix: An Amazon S3 object key prefix that you can use to limit signed objects keys to begin with the specified prefix... |
@property
@pulumi.getter
def bucket(self) -> pulumi.Input[str]:
'\n Name of the S3 bucket.\n '
return pulumi.get(self, 'bucket') | -1,710,090,463,754,171,000 | Name of the S3 bucket. | sdk/python/pulumi_aws/signer/_inputs.py | bucket | chivandikwa/pulumi-aws | python | @property
@pulumi.getter
def bucket(self) -> pulumi.Input[str]:
'\n \n '
return pulumi.get(self, 'bucket') |
@property
@pulumi.getter
def prefix(self) -> Optional[pulumi.Input[str]]:
'\n An Amazon S3 object key prefix that you can use to limit signed objects keys to begin with the specified prefix.\n '
return pulumi.get(self, 'prefix') | 4,363,513,374,241,139,000 | An Amazon S3 object key prefix that you can use to limit signed objects keys to begin with the specified prefix. | sdk/python/pulumi_aws/signer/_inputs.py | prefix | chivandikwa/pulumi-aws | python | @property
@pulumi.getter
def prefix(self) -> Optional[pulumi.Input[str]]:
'\n \n '
return pulumi.get(self, 'prefix') |
def __init__(__self__, *, s3s: Optional[pulumi.Input[Sequence[pulumi.Input['SigningJobSignedObjectS3Args']]]]=None):
"\n :param pulumi.Input[Sequence[pulumi.Input['SigningJobSignedObjectS3Args']]] s3s: A configuration block describing the S3 Destination object: See S3 Destination below for details.\n ... | 8,890,170,183,575,213,000 | :param pulumi.Input[Sequence[pulumi.Input['SigningJobSignedObjectS3Args']]] s3s: A configuration block describing the S3 Destination object: See S3 Destination below for details. | sdk/python/pulumi_aws/signer/_inputs.py | __init__ | chivandikwa/pulumi-aws | python | def __init__(__self__, *, s3s: Optional[pulumi.Input[Sequence[pulumi.Input['SigningJobSignedObjectS3Args']]]]=None):
"\n \n "
if (s3s is not None):
pulumi.set(__self__, 's3s', s3s) |
@property
@pulumi.getter
def s3s(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['SigningJobSignedObjectS3Args']]]]:
'\n A configuration block describing the S3 Destination object: See S3 Destination below for details.\n '
return pulumi.get(self, 's3s') | 8,498,705,302,498,874,000 | A configuration block describing the S3 Destination object: See S3 Destination below for details. | sdk/python/pulumi_aws/signer/_inputs.py | s3s | chivandikwa/pulumi-aws | python | @property
@pulumi.getter
def s3s(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['SigningJobSignedObjectS3Args']]]]:
'\n \n '
return pulumi.get(self, 's3s') |
def __init__(__self__, *, bucket: Optional[pulumi.Input[str]]=None, key: Optional[pulumi.Input[str]]=None):
'\n :param pulumi.Input[str] bucket: Name of the S3 bucket.\n :param pulumi.Input[str] key: Key name of the object that contains your unsigned code.\n '
if (bucket is not None):
... | 7,574,837,572,411,065,000 | :param pulumi.Input[str] bucket: Name of the S3 bucket.
:param pulumi.Input[str] key: Key name of the object that contains your unsigned code. | sdk/python/pulumi_aws/signer/_inputs.py | __init__ | chivandikwa/pulumi-aws | python | def __init__(__self__, *, bucket: Optional[pulumi.Input[str]]=None, key: Optional[pulumi.Input[str]]=None):
'\n :param pulumi.Input[str] bucket: Name of the S3 bucket.\n :param pulumi.Input[str] key: Key name of the object that contains your unsigned code.\n '
if (bucket is not None):
... |
@property
@pulumi.getter
def bucket(self) -> Optional[pulumi.Input[str]]:
'\n Name of the S3 bucket.\n '
return pulumi.get(self, 'bucket') | 7,665,507,557,751,155,000 | Name of the S3 bucket. | sdk/python/pulumi_aws/signer/_inputs.py | bucket | chivandikwa/pulumi-aws | python | @property
@pulumi.getter
def bucket(self) -> Optional[pulumi.Input[str]]:
'\n \n '
return pulumi.get(self, 'bucket') |
@property
@pulumi.getter
def key(self) -> Optional[pulumi.Input[str]]:
'\n Key name of the object that contains your unsigned code.\n '
return pulumi.get(self, 'key') | -8,948,908,011,397,422,000 | Key name of the object that contains your unsigned code. | sdk/python/pulumi_aws/signer/_inputs.py | key | chivandikwa/pulumi-aws | python | @property
@pulumi.getter
def key(self) -> Optional[pulumi.Input[str]]:
'\n \n '
return pulumi.get(self, 'key') |
def __init__(__self__, *, s3: pulumi.Input['SigningJobSourceS3Args']):
"\n :param pulumi.Input['SigningJobSourceS3Args'] s3: A configuration block describing the S3 Destination object: See S3 Destination below for details.\n "
pulumi.set(__self__, 's3', s3) | -6,220,106,824,449,930,000 | :param pulumi.Input['SigningJobSourceS3Args'] s3: A configuration block describing the S3 Destination object: See S3 Destination below for details. | sdk/python/pulumi_aws/signer/_inputs.py | __init__ | chivandikwa/pulumi-aws | python | def __init__(__self__, *, s3: pulumi.Input['SigningJobSourceS3Args']):
"\n \n "
pulumi.set(__self__, 's3', s3) |
@property
@pulumi.getter
def s3(self) -> pulumi.Input['SigningJobSourceS3Args']:
'\n A configuration block describing the S3 Destination object: See S3 Destination below for details.\n '
return pulumi.get(self, 's3') | 3,627,296,741,726,690,300 | A configuration block describing the S3 Destination object: See S3 Destination below for details. | sdk/python/pulumi_aws/signer/_inputs.py | s3 | chivandikwa/pulumi-aws | python | @property
@pulumi.getter
def s3(self) -> pulumi.Input['SigningJobSourceS3Args']:
'\n \n '
return pulumi.get(self, 's3') |
def __init__(__self__, *, bucket: pulumi.Input[str], key: pulumi.Input[str], version: pulumi.Input[str]):
'\n :param pulumi.Input[str] bucket: Name of the S3 bucket.\n :param pulumi.Input[str] key: Key name of the object that contains your unsigned code.\n :param pulumi.Input[str] version: Vers... | 1,291,970,849,343,384,000 | :param pulumi.Input[str] bucket: Name of the S3 bucket.
:param pulumi.Input[str] key: Key name of the object that contains your unsigned code.
:param pulumi.Input[str] version: Version of your source image in your version enabled S3 bucket. | sdk/python/pulumi_aws/signer/_inputs.py | __init__ | chivandikwa/pulumi-aws | python | def __init__(__self__, *, bucket: pulumi.Input[str], key: pulumi.Input[str], version: pulumi.Input[str]):
'\n :param pulumi.Input[str] bucket: Name of the S3 bucket.\n :param pulumi.Input[str] key: Key name of the object that contains your unsigned code.\n :param pulumi.Input[str] version: Vers... |
@property
@pulumi.getter
def bucket(self) -> pulumi.Input[str]:
'\n Name of the S3 bucket.\n '
return pulumi.get(self, 'bucket') | -1,710,090,463,754,171,000 | Name of the S3 bucket. | sdk/python/pulumi_aws/signer/_inputs.py | bucket | chivandikwa/pulumi-aws | python | @property
@pulumi.getter
def bucket(self) -> pulumi.Input[str]:
'\n \n '
return pulumi.get(self, 'bucket') |
@property
@pulumi.getter
def key(self) -> pulumi.Input[str]:
'\n Key name of the object that contains your unsigned code.\n '
return pulumi.get(self, 'key') | 836,810,978,507,954,400 | Key name of the object that contains your unsigned code. | sdk/python/pulumi_aws/signer/_inputs.py | key | chivandikwa/pulumi-aws | python | @property
@pulumi.getter
def key(self) -> pulumi.Input[str]:
'\n \n '
return pulumi.get(self, 'key') |
@property
@pulumi.getter
def version(self) -> pulumi.Input[str]:
'\n Version of your source image in your version enabled S3 bucket.\n '
return pulumi.get(self, 'version') | 1,773,487,770,454,480,000 | Version of your source image in your version enabled S3 bucket. | sdk/python/pulumi_aws/signer/_inputs.py | version | chivandikwa/pulumi-aws | python | @property
@pulumi.getter
def version(self) -> pulumi.Input[str]:
'\n \n '
return pulumi.get(self, 'version') |
def stations_level_over_threshold(stations: list, tol: float) -> list:
'function takes in stations and returns a list of tuples contating station and\n relative water lever where the relative water level greater than tol '
stations = consistant_typical_range_stations(stations)
res_list = []
for stati... | 3,081,818,777,980,905,500 | function takes in stations and returns a list of tuples contating station and
relative water lever where the relative water level greater than tol | floodsystem/flood.py | stations_level_over_threshold | LakeeSiv/Flood | python | def stations_level_over_threshold(stations: list, tol: float) -> list:
'function takes in stations and returns a list of tuples contating station and\n relative water lever where the relative water level greater than tol '
stations = consistant_typical_range_stations(stations)
res_list = []
for stati... |
def stations_highest_rel_level(stations, N):
'Returns a list of N MonitoringStation objects ordered from highest to lowest risk'
stations = consistant_typical_range_stations(stations)
def key(x):
if (x.relative_water_level() is not None):
return x.relative_water_level()
else:
... | -7,452,110,879,722,056,000 | Returns a list of N MonitoringStation objects ordered from highest to lowest risk | floodsystem/flood.py | stations_highest_rel_level | LakeeSiv/Flood | python | def stations_highest_rel_level(stations, N):
stations = consistant_typical_range_stations(stations)
def key(x):
if (x.relative_water_level() is not None):
return x.relative_water_level()
else:
return float(0)
stationByHighestLevel = sorted(stations, key=key, rev... |
def get_network_interface_tap_configuration(network_interface_name: Optional[str]=None, resource_group_name: Optional[str]=None, tap_configuration_name: Optional[str]=None, opts: Optional[pulumi.InvokeOptions]=None) -> AwaitableGetNetworkInterfaceTapConfigurationResult:
'\n Use this data source to access informa... | -1,626,526,267,666,726,700 | Use this data source to access information about an existing resource.
:param str network_interface_name: The name of the network interface.
:param str resource_group_name: The name of the resource group.
:param str tap_configuration_name: The name of the tap configuration. | sdk/python/pulumi_azure_nextgen/network/v20200301/get_network_interface_tap_configuration.py | get_network_interface_tap_configuration | test-wiz-sec/pulumi-azure-nextgen | python | def get_network_interface_tap_configuration(network_interface_name: Optional[str]=None, resource_group_name: Optional[str]=None, tap_configuration_name: Optional[str]=None, opts: Optional[pulumi.InvokeOptions]=None) -> AwaitableGetNetworkInterfaceTapConfigurationResult:
'\n Use this data source to access informa... |
@property
@pulumi.getter
def etag(self) -> str:
'\n A unique read-only string that changes whenever the resource is updated.\n '
return pulumi.get(self, 'etag') | -4,757,010,955,465,940,000 | A unique read-only string that changes whenever the resource is updated. | sdk/python/pulumi_azure_nextgen/network/v20200301/get_network_interface_tap_configuration.py | etag | test-wiz-sec/pulumi-azure-nextgen | python | @property
@pulumi.getter
def etag(self) -> str:
'\n \n '
return pulumi.get(self, 'etag') |
@property
@pulumi.getter
def name(self) -> Optional[str]:
'\n The name of the resource that is unique within a resource group. This name can be used to access the resource.\n '
return pulumi.get(self, 'name') | 7,871,952,733,487,996,000 | The name of the resource that is unique within a resource group. This name can be used to access the resource. | sdk/python/pulumi_azure_nextgen/network/v20200301/get_network_interface_tap_configuration.py | name | test-wiz-sec/pulumi-azure-nextgen | python | @property
@pulumi.getter
def name(self) -> Optional[str]:
'\n \n '
return pulumi.get(self, 'name') |
@property
@pulumi.getter(name='provisioningState')
def provisioning_state(self) -> str:
'\n The provisioning state of the network interface tap configuration resource.\n '
return pulumi.get(self, 'provisioning_state') | 2,762,668,277,548,461,600 | The provisioning state of the network interface tap configuration resource. | sdk/python/pulumi_azure_nextgen/network/v20200301/get_network_interface_tap_configuration.py | provisioning_state | test-wiz-sec/pulumi-azure-nextgen | python | @property
@pulumi.getter(name='provisioningState')
def provisioning_state(self) -> str:
'\n \n '
return pulumi.get(self, 'provisioning_state') |
@property
@pulumi.getter
def type(self) -> str:
'\n Sub Resource type.\n '
return pulumi.get(self, 'type') | -1,978,523,207,940,031,500 | Sub Resource type. | sdk/python/pulumi_azure_nextgen/network/v20200301/get_network_interface_tap_configuration.py | type | test-wiz-sec/pulumi-azure-nextgen | python | @property
@pulumi.getter
def type(self) -> str:
'\n \n '
return pulumi.get(self, 'type') |
@property
@pulumi.getter(name='virtualNetworkTap')
def virtual_network_tap(self) -> Optional['outputs.VirtualNetworkTapResponse']:
'\n The reference to the Virtual Network Tap resource.\n '
return pulumi.get(self, 'virtual_network_tap') | 8,563,566,634,166,654,000 | The reference to the Virtual Network Tap resource. | sdk/python/pulumi_azure_nextgen/network/v20200301/get_network_interface_tap_configuration.py | virtual_network_tap | test-wiz-sec/pulumi-azure-nextgen | python | @property
@pulumi.getter(name='virtualNetworkTap')
def virtual_network_tap(self) -> Optional['outputs.VirtualNetworkTapResponse']:
'\n \n '
return pulumi.get(self, 'virtual_network_tap') |
def wrap_deepmind(env, episode_life=True, clip_rewards=True, frame_stack=False, scale=False):
'Configure environment for DeepMind-style Atari.\n '
if episode_life:
env = EpisodicLifeEnv(env)
if ('FIRE' in env.unwrapped.get_action_meanings()):
env = FireResetEnv(env)
env = WarpFrame(en... | 8,419,616,476,582,256,000 | Configure environment for DeepMind-style Atari. | cleanrl/experiments/dqn2_atari_visual.py | wrap_deepmind | HelgeS/cleanrl | python | def wrap_deepmind(env, episode_life=True, clip_rewards=True, frame_stack=False, scale=False):
'\n '
if episode_life:
env = EpisodicLifeEnv(env)
if ('FIRE' in env.unwrapped.get_action_meanings()):
env = FireResetEnv(env)
env = WarpFrame(env)
if scale:
env = ScaledFloatFrame... |
def __init__(self, env, noop_max=30):
'Sample initial states by taking random number of no-ops on reset.\n No-op is assumed to be action 0.\n '
gym.Wrapper.__init__(self, env)
self.noop_max = noop_max
self.override_num_noops = None
self.noop_action = 0
assert (env.unwrapped.get_act... | -3,116,499,769,739,602,000 | Sample initial states by taking random number of no-ops on reset.
No-op is assumed to be action 0. | cleanrl/experiments/dqn2_atari_visual.py | __init__ | HelgeS/cleanrl | python | def __init__(self, env, noop_max=30):
'Sample initial states by taking random number of no-ops on reset.\n No-op is assumed to be action 0.\n '
gym.Wrapper.__init__(self, env)
self.noop_max = noop_max
self.override_num_noops = None
self.noop_action = 0
assert (env.unwrapped.get_act... |
def reset(self, **kwargs):
' Do no-op action for a number of steps in [1, noop_max].'
self.env.reset(**kwargs)
if (self.override_num_noops is not None):
noops = self.override_num_noops
else:
noops = self.unwrapped.np_random.randint(1, (self.noop_max + 1))
assert (noops > 0)
obs =... | -3,653,542,374,860,504,600 | Do no-op action for a number of steps in [1, noop_max]. | cleanrl/experiments/dqn2_atari_visual.py | reset | HelgeS/cleanrl | python | def reset(self, **kwargs):
' '
self.env.reset(**kwargs)
if (self.override_num_noops is not None):
noops = self.override_num_noops
else:
noops = self.unwrapped.np_random.randint(1, (self.noop_max + 1))
assert (noops > 0)
obs = None
for _ in range(noops):
(obs, _, done,... |
def __init__(self, env):
'Take action on reset for environments that are fixed until firing.'
gym.Wrapper.__init__(self, env)
assert (env.unwrapped.get_action_meanings()[1] == 'FIRE')
assert (len(env.unwrapped.get_action_meanings()) >= 3) | -4,566,798,254,225,915,400 | Take action on reset for environments that are fixed until firing. | cleanrl/experiments/dqn2_atari_visual.py | __init__ | HelgeS/cleanrl | python | def __init__(self, env):
gym.Wrapper.__init__(self, env)
assert (env.unwrapped.get_action_meanings()[1] == 'FIRE')
assert (len(env.unwrapped.get_action_meanings()) >= 3) |
def __init__(self, env):
'Make end-of-life == end-of-episode, but only reset on true game over.\n Done by DeepMind for the DQN and co. since it helps value estimation.\n '
gym.Wrapper.__init__(self, env)
self.lives = 0
self.was_real_done = True | 8,971,507,481,187,434,000 | Make end-of-life == end-of-episode, but only reset on true game over.
Done by DeepMind for the DQN and co. since it helps value estimation. | cleanrl/experiments/dqn2_atari_visual.py | __init__ | HelgeS/cleanrl | python | def __init__(self, env):
'Make end-of-life == end-of-episode, but only reset on true game over.\n Done by DeepMind for the DQN and co. since it helps value estimation.\n '
gym.Wrapper.__init__(self, env)
self.lives = 0
self.was_real_done = True |
def reset(self, **kwargs):
'Reset only when lives are exhausted.\n This way all states are still reachable even though lives are episodic,\n and the learner need not know about any of this behind-the-scenes.\n '
if self.was_real_done:
obs = self.env.reset(**kwargs)
else:
... | 6,497,171,709,227,915,000 | Reset only when lives are exhausted.
This way all states are still reachable even though lives are episodic,
and the learner need not know about any of this behind-the-scenes. | cleanrl/experiments/dqn2_atari_visual.py | reset | HelgeS/cleanrl | python | def reset(self, **kwargs):
'Reset only when lives are exhausted.\n This way all states are still reachable even though lives are episodic,\n and the learner need not know about any of this behind-the-scenes.\n '
if self.was_real_done:
obs = self.env.reset(**kwargs)
else:
... |
def __init__(self, env, skip=4):
'Return only every `skip`-th frame'
gym.Wrapper.__init__(self, env)
self._obs_buffer = np.zeros(((2,) + env.observation_space.shape), dtype=np.uint8)
self._skip = skip | -1,973,326,398,823,476,000 | Return only every `skip`-th frame | cleanrl/experiments/dqn2_atari_visual.py | __init__ | HelgeS/cleanrl | python | def __init__(self, env, skip=4):
gym.Wrapper.__init__(self, env)
self._obs_buffer = np.zeros(((2,) + env.observation_space.shape), dtype=np.uint8)
self._skip = skip |
def step(self, action):
'Repeat action, sum reward, and max over last observations.'
total_reward = 0.0
done = None
for i in range(self._skip):
(obs, reward, done, info) = self.env.step(action)
if (i == (self._skip - 2)):
self._obs_buffer[0] = obs
if (i == (self._skip... | -8,302,944,132,917,912,000 | Repeat action, sum reward, and max over last observations. | cleanrl/experiments/dqn2_atari_visual.py | step | HelgeS/cleanrl | python | def step(self, action):
total_reward = 0.0
done = None
for i in range(self._skip):
(obs, reward, done, info) = self.env.step(action)
if (i == (self._skip - 2)):
self._obs_buffer[0] = obs
if (i == (self._skip - 1)):
self._obs_buffer[1] = obs
total_... |
def reward(self, reward):
'Bin reward to {+1, 0, -1} by its sign.'
return np.sign(reward) | -3,165,823,258,035,945,500 | Bin reward to {+1, 0, -1} by its sign. | cleanrl/experiments/dqn2_atari_visual.py | reward | HelgeS/cleanrl | python | def reward(self, reward):
return np.sign(reward) |
def __init__(self, env, width=84, height=84, grayscale=True, dict_space_key=None):
'\n Warp frames to 84x84 as done in the Nature paper and later work.\n If the environment uses dictionary observations, `dict_space_key` can be specified which indicates which\n observation should be warped.\n ... | -1,792,364,871,353,848,800 | Warp frames to 84x84 as done in the Nature paper and later work.
If the environment uses dictionary observations, `dict_space_key` can be specified which indicates which
observation should be warped. | cleanrl/experiments/dqn2_atari_visual.py | __init__ | HelgeS/cleanrl | python | def __init__(self, env, width=84, height=84, grayscale=True, dict_space_key=None):
'\n Warp frames to 84x84 as done in the Nature paper and later work.\n If the environment uses dictionary observations, `dict_space_key` can be specified which indicates which\n observation should be warped.\n ... |
def __init__(self, env, k):
'Stack k last frames.\n Returns lazy array, which is much more memory efficient.\n See Also\n --------\n baselines.common.atari_wrappers.LazyFrames\n '
gym.Wrapper.__init__(self, env)
self.k = k
self.frames = deque([], maxlen=k)
shp = en... | 3,172,038,940,569,455,600 | Stack k last frames.
Returns lazy array, which is much more memory efficient.
See Also
--------
baselines.common.atari_wrappers.LazyFrames | cleanrl/experiments/dqn2_atari_visual.py | __init__ | HelgeS/cleanrl | python | def __init__(self, env, k):
'Stack k last frames.\n Returns lazy array, which is much more memory efficient.\n See Also\n --------\n baselines.common.atari_wrappers.LazyFrames\n '
gym.Wrapper.__init__(self, env)
self.k = k
self.frames = deque([], maxlen=k)
shp = en... |
def __init__(self, frames):
"This object ensures that common frames between the observations are only stored once.\n It exists purely to optimize memory usage which can be huge for DQN's 1M frames replay\n buffers.\n This object should only be converted to numpy array before being passed to the... | -6,724,169,720,603,208,000 | This object ensures that common frames between the observations are only stored once.
It exists purely to optimize memory usage which can be huge for DQN's 1M frames replay
buffers.
This object should only be converted to numpy array before being passed to the model.
You'd not believe how complex the previous solution ... | cleanrl/experiments/dqn2_atari_visual.py | __init__ | HelgeS/cleanrl | python | def __init__(self, frames):
"This object ensures that common frames between the observations are only stored once.\n It exists purely to optimize memory usage which can be huge for DQN's 1M frames replay\n buffers.\n This object should only be converted to numpy array before being passed to the... |
def run_job_and_check_output(self, expected_output, sort=False, literal_eval=False):
'Helper function to run job and compare output.'
job_id = self.job_class.create_new()
self.assertEqual(self.count_jobs_in_taskqueue(taskqueue_services.QUEUE_NAME_ONE_OFF_JOBS), 0)
self.job_class.enqueue(job_id)
self... | -1,385,014,196,414,906,400 | Helper function to run job and compare output. | core/domain/prod_validation_jobs_one_off_test.py | run_job_and_check_output | cclauss/oppia | python | def run_job_and_check_output(self, expected_output, sort=False, literal_eval=False):
job_id = self.job_class.create_new()
self.assertEqual(self.count_jobs_in_taskqueue(taskqueue_services.QUEUE_NAME_ONE_OFF_JOBS), 0)
self.job_class.enqueue(job_id)
self.assertEqual(self.count_jobs_in_taskqueue(taskqu... |
def update_datastore_types_for_mock_datetime():
'Updates datastore types for MockDatetime13Hours to ensure that validation\n of ndb datetime properties does not fail.\n '
datastore_types._VALIDATE_PROPERTY_VALUES[MockDatetime13Hours] = datastore_types.ValidatePropertyNothing
datastore_types._PACK_PROP... | 5,530,078,662,511,757,000 | Updates datastore types for MockDatetime13Hours to ensure that validation
of ndb datetime properties does not fail. | core/domain/prod_validation_jobs_one_off_test.py | update_datastore_types_for_mock_datetime | cclauss/oppia | python | def update_datastore_types_for_mock_datetime():
'Updates datastore types for MockDatetime13Hours to ensure that validation\n of ndb datetime properties does not fail.\n '
datastore_types._VALIDATE_PROPERTY_VALUES[MockDatetime13Hours] = datastore_types.ValidatePropertyNothing
datastore_types._PACK_PROP... |
def __instancecheck__(cls, other):
'Validates whether the given instance is a datatime\n instance.\n '
return isinstance(other, OriginalDatetimeType) | 629,265,886,878,505,000 | Validates whether the given instance is a datatime
instance. | core/domain/prod_validation_jobs_one_off_test.py | __instancecheck__ | cclauss/oppia | python | def __instancecheck__(cls, other):
'Validates whether the given instance is a datatime\n instance.\n '
return isinstance(other, OriginalDatetimeType) |
@classmethod
def utcnow(cls):
'Returns the current date and time 13 hours behind UTC.'
return (CURRENT_DATETIME - datetime.timedelta(hours=13)) | -6,697,928,566,259,835,000 | Returns the current date and time 13 hours behind UTC. | core/domain/prod_validation_jobs_one_off_test.py | utcnow | cclauss/oppia | python | @classmethod
def utcnow(cls):
return (CURRENT_DATETIME - datetime.timedelta(hours=13)) |
def backward(self, top, propagate_down, bottom):
'This layer does not propagate gradients.'
pass | 8,785,054,024,326,067,000 | This layer does not propagate gradients. | lib/model/rpn/proposal_layer.py | backward | busyboxs/pytorch-faster-rcnn | python | def backward(self, top, propagate_down, bottom):
pass |
def reshape(self, bottom, top):
'Reshaping happens during the call to forward.'
pass | -1,223,691,358,648,909,800 | Reshaping happens during the call to forward. | lib/model/rpn/proposal_layer.py | reshape | busyboxs/pytorch-faster-rcnn | python | def reshape(self, bottom, top):
pass |
def _filter_boxes(self, boxes, min_size):
'Remove all boxes with any side smaller than min_size.'
ws = ((boxes[:, :, 2] - boxes[:, :, 0]) + 1)
hs = ((boxes[:, :, 3] - boxes[:, :, 1]) + 1)
keep = ((ws >= min_size.view((- 1), 1).expand_as(ws)) & (hs >= min_size.view((- 1), 1).expand_as(hs)))
return ke... | 1,782,366,848,494,310,100 | Remove all boxes with any side smaller than min_size. | lib/model/rpn/proposal_layer.py | _filter_boxes | busyboxs/pytorch-faster-rcnn | python | def _filter_boxes(self, boxes, min_size):
ws = ((boxes[:, :, 2] - boxes[:, :, 0]) + 1)
hs = ((boxes[:, :, 3] - boxes[:, :, 1]) + 1)
keep = ((ws >= min_size.view((- 1), 1).expand_as(ws)) & (hs >= min_size.view((- 1), 1).expand_as(hs)))
return keep |
@skipUnlessDarwin
@add_test_categories(['pyapi'])
def test_objc_properties(self):
'Test that expr uses the correct property getters and setters'
if (self.getArchitecture() == 'i386'):
self.skipTest('requires modern objc runtime')
self.build()
exe = os.path.join(os.getcwd(), 'a.out')
target =... | 8,712,816,977,307,540,000 | Test that expr uses the correct property getters and setters | SymbolExtractorAndRenamer/lldb/packages/Python/lldbsuite/test/lang/objc/objc-property/TestObjCProperty.py | test_objc_properties | Polidea/SiriusObfuscator | python | @skipUnlessDarwin
@add_test_categories(['pyapi'])
def test_objc_properties(self):
if (self.getArchitecture() == 'i386'):
self.skipTest('requires modern objc runtime')
self.build()
exe = os.path.join(os.getcwd(), 'a.out')
target = self.dbg.CreateTarget(exe)
self.assertTrue(target, VALID_... |
def get_commit_distance_version(repo_dir: str, version: Version, latest_tag: str) -> Optional[Version]:
'\n This function creates a string which describes the version of the\n monorepo or package that includes the commit distance and SHA revision\n number.\n\n For a mono repository, the full commit distance is ... | 7,152,067,297,977,686,000 | This function creates a string which describes the version of the
monorepo or package that includes the commit distance and SHA revision
number.
For a mono repository, the full commit distance is used. The same is true
for a single package. For a package inside a mono repository that does not
apply mono versioning, th... | src/shut/model/version.py | get_commit_distance_version | NiklasRosenstein/shut | python | def get_commit_distance_version(repo_dir: str, version: Version, latest_tag: str) -> Optional[Version]:
'\n This function creates a string which describes the version of the\n monorepo or package that includes the commit distance and SHA revision\n number.\n\n For a mono repository, the full commit distance is ... |
def extend_with_language_model(BaseModel):
'添加下三角的Attention Mask(语言模型用)\n '
class LanguageModel(LM_Mask, BaseModel):
'带下三角Attention Mask的派生模型\n '
def __init__(self, *args, **kwargs):
super(LanguageModel, self).__init__(*args, **kwargs)
self.with_mlm = (self.wi... | -374,363,184,057,374,100 | 添加下三角的Attention Mask(语言模型用) | bert4keras/models.py | extend_with_language_model | CurisZhou/bert4keras | python | def extend_with_language_model(BaseModel):
'\n '
class LanguageModel(LM_Mask, BaseModel):
'带下三角Attention Mask的派生模型\n '
def __init__(self, *args, **kwargs):
super(LanguageModel, self).__init__(*args, **kwargs)
self.with_mlm = (self.with_mlm or True)
return ... |
def extend_with_unified_language_model(BaseModel):
'添加UniLM的Attention Mask(Seq2Seq模型用)\n '
class UnifiedLanguageModel(UniLM_Mask, BaseModel):
'带UniLM的Attention Mask的派生模型\n UniLM: https://arxiv.org/abs/1905.03197\n '
def __init__(self, *args, **kwargs):
super(Unifie... | -1,459,502,272,783,444,500 | 添加UniLM的Attention Mask(Seq2Seq模型用) | bert4keras/models.py | extend_with_unified_language_model | CurisZhou/bert4keras | python | def extend_with_unified_language_model(BaseModel):
'\n '
class UnifiedLanguageModel(UniLM_Mask, BaseModel):
'带UniLM的Attention Mask的派生模型\n UniLM: https://arxiv.org/abs/1905.03197\n '
def __init__(self, *args, **kwargs):
super(UnifiedLanguageModel, self).__init__(*ar... |
def build_transformer_model(config_path=None, checkpoint_path=None, model='bert', application='encoder', return_keras_model=True, **kwargs):
'根据配置文件构建模型,可选加载checkpoint权重\n '
configs = {}
if (config_path is not None):
configs.update(json.load(open(config_path)))
configs.update(kwargs)
if (... | -4,409,276,050,895,325,000 | 根据配置文件构建模型,可选加载checkpoint权重 | bert4keras/models.py | build_transformer_model | CurisZhou/bert4keras | python | def build_transformer_model(config_path=None, checkpoint_path=None, model='bert', application='encoder', return_keras_model=True, **kwargs):
'\n '
configs = {}
if (config_path is not None):
configs.update(json.load(open(config_path)))
configs.update(kwargs)
if ('max_position' not in confi... |
def build(self, attention_caches=None, layer_norm_cond=None, layer_norm_cond_hidden_size=None, layer_norm_cond_hidden_act=None, additional_input_layers=None, **kwargs):
'模型构建函数\n attention_caches:为Attention的K,V的缓存序列字典,格式为\n {Attention层名: [K缓存, V缓存]};\n layer_norm_*系列参数:实现Condit... | 3,740,199,043,613,940,000 | 模型构建函数
attention_caches:为Attention的K,V的缓存序列字典,格式为
{Attention层名: [K缓存, V缓存]};
layer_norm_*系列参数:实现Conditional Layer Normalization时使用,
用来实现以“固定长度向量”为条件的条件Bert。 | bert4keras/models.py | build | CurisZhou/bert4keras | python | def build(self, attention_caches=None, layer_norm_cond=None, layer_norm_cond_hidden_size=None, layer_norm_cond_hidden_act=None, additional_input_layers=None, **kwargs):
'模型构建函数\n attention_caches:为Attention的K,V的缓存序列字典,格式为\n {Attention层名: [K缓存, V缓存]};\n layer_norm_*系列参数:实现Condit... |
def call(self, inputs):
'定义模型的执行流程\n '
outputs = self.apply_embeddings(inputs)
for i in range(self.num_hidden_layers):
outputs = self.apply_main_layers(outputs, i)
outputs = self.apply_final_layers(outputs)
return outputs | -6,229,499,654,623,413,000 | 定义模型的执行流程 | bert4keras/models.py | call | CurisZhou/bert4keras | python | def call(self, inputs):
'\n '
outputs = self.apply_embeddings(inputs)
for i in range(self.num_hidden_layers):
outputs = self.apply_main_layers(outputs, i)
outputs = self.apply_final_layers(outputs)
return outputs |
def prefixed(self, name):
'给名字加前缀\n '
if (name is not None):
return (self.prefix + name) | -4,764,178,677,985,925,000 | 给名字加前缀 | bert4keras/models.py | prefixed | CurisZhou/bert4keras | python | def prefixed(self, name):
'\n '
if (name is not None):
return (self.prefix + name) |
def apply(self, inputs=None, layer=None, arguments=None, **kwargs):
'通过apply调用层会自动重用同名层\n inputs: 上一层的输出;\n layer: 要调用的层类名;\n arguments: 传递给layer.call的参数;\n kwargs: 传递给层初始化的参数。\n '
if ((layer is Dropout) and (self.dropout_rate == 0)):
return inputs
if ((layer is Mu... | -4,756,943,625,493,727,000 | 通过apply调用层会自动重用同名层
inputs: 上一层的输出;
layer: 要调用的层类名;
arguments: 传递给layer.call的参数;
kwargs: 传递给层初始化的参数。 | bert4keras/models.py | apply | CurisZhou/bert4keras | python | def apply(self, inputs=None, layer=None, arguments=None, **kwargs):
'通过apply调用层会自动重用同名层\n inputs: 上一层的输出;\n layer: 要调用的层类名;\n arguments: 传递给layer.call的参数;\n kwargs: 传递给层初始化的参数。\n '
if ((layer is Dropout) and (self.dropout_rate == 0)):
return inputs
if ((layer is Mu... |
def compute_attention_bias(self, inputs=None):
'定义每一层的Attention Bias\n '
return self.attention_bias | -1,749,003,794,285,315,800 | 定义每一层的Attention Bias | bert4keras/models.py | compute_attention_bias | CurisZhou/bert4keras | python | def compute_attention_bias(self, inputs=None):
'\n '
return self.attention_bias |
def compute_position_bias(self, inputs=None):
'定义每一层的Position Bias(一般相对位置编码用)\n '
return self.position_bias | -8,838,572,378,965,173,000 | 定义每一层的Position Bias(一般相对位置编码用) | bert4keras/models.py | compute_position_bias | CurisZhou/bert4keras | python | def compute_position_bias(self, inputs=None):
'\n '
return self.position_bias |
def set_inputs(self, inputs, additional_input_layers=None):
'设置input和inputs属性\n '
if (inputs is None):
inputs = []
elif (not isinstance(inputs, list)):
inputs = [inputs]
inputs = inputs[:]
if (additional_input_layers is not None):
if (not isinstance(additional_input_la... | -2,619,954,512,554,763,300 | 设置input和inputs属性 | bert4keras/models.py | set_inputs | CurisZhou/bert4keras | python | def set_inputs(self, inputs, additional_input_layers=None):
'\n '
if (inputs is None):
inputs = []
elif (not isinstance(inputs, list)):
inputs = [inputs]
inputs = inputs[:]
if (additional_input_layers is not None):
if (not isinstance(additional_input_layers, list)):
... |
def set_outputs(self, outputs):
'设置output和oututs属性\n '
if (not isinstance(outputs, list)):
outputs = [outputs]
outputs = outputs[:]
self.outputs = outputs
if (len(outputs) > 1):
self.output = outputs
else:
self.output = outputs[0] | -4,584,545,269,230,479,000 | 设置output和oututs属性 | bert4keras/models.py | set_outputs | CurisZhou/bert4keras | python | def set_outputs(self, outputs):
'\n '
if (not isinstance(outputs, list)):
outputs = [outputs]
outputs = outputs[:]
self.outputs = outputs
if (len(outputs) > 1):
self.output = outputs
else:
self.output = outputs[0] |
@property
def initializer(self):
'默认使用截断正态分布初始化\n '
return keras.initializers.TruncatedNormal(stddev=0.02) | 7,058,008,652,299,686,000 | 默认使用截断正态分布初始化 | bert4keras/models.py | initializer | CurisZhou/bert4keras | python | @property
def initializer(self):
'\n '
return keras.initializers.TruncatedNormal(stddev=0.02) |
def simplify(self, inputs):
'将list中的None过滤掉\n '
inputs = [i for i in inputs if (i is not None)]
if (len(inputs) == 1):
inputs = inputs[0]
return inputs | 887,025,803,912,393,000 | 将list中的None过滤掉 | bert4keras/models.py | simplify | CurisZhou/bert4keras | python | def simplify(self, inputs):
'\n '
inputs = [i for i in inputs if (i is not None)]
if (len(inputs) == 1):
inputs = inputs[0]
return inputs |
def load_embeddings(self, embeddings):
'处理Embedding层权重\n '
if (self.keep_tokens is not None):
embeddings = embeddings[self.keep_tokens]
if (self.compound_tokens is not None):
ext_embeddings = []
for item in self.compound_tokens:
if isinstance(item, list):
... | -4,447,431,261,012,996,600 | 处理Embedding层权重 | bert4keras/models.py | load_embeddings | CurisZhou/bert4keras | python | def load_embeddings(self, embeddings):
'\n '
if (self.keep_tokens is not None):
embeddings = embeddings[self.keep_tokens]
if (self.compound_tokens is not None):
ext_embeddings = []
for item in self.compound_tokens:
if isinstance(item, list):
item = ... |
def load_variable(self, checkpoint, name):
'加载单个变量的函数\n '
if isinstance(checkpoint, dict):
return checkpoint[name]
else:
return tf.train.load_variable(checkpoint, name) | 2,776,577,819,828,255,000 | 加载单个变量的函数 | bert4keras/models.py | load_variable | CurisZhou/bert4keras | python | def load_variable(self, checkpoint, name):
'\n '
if isinstance(checkpoint, dict):
return checkpoint[name]
else:
return tf.train.load_variable(checkpoint, name) |
def create_variable(self, name, value, dtype=None):
'创建一个变量\n '
dtype = (dtype or K.floatx())
return (K.variable(self.initializer(value.shape, dtype), dtype, name=name), value) | -6,833,356,355,497,773,000 | 创建一个变量 | bert4keras/models.py | create_variable | CurisZhou/bert4keras | python | def create_variable(self, name, value, dtype=None):
'\n '
dtype = (dtype or K.floatx())
return (K.variable(self.initializer(value.shape, dtype), dtype, name=name), value) |
def variable_mapping(self):
'构建keras层与checkpoint的变量名之间的映射表\n '
return {} | -7,573,230,003,583,619,000 | 构建keras层与checkpoint的变量名之间的映射表 | bert4keras/models.py | variable_mapping | CurisZhou/bert4keras | python | def variable_mapping(self):
'\n '
return {} |
def load_weights_from_checkpoint(self, checkpoint, mapping=None):
'根据mapping从checkpoint加载权重\n '
mapping = (mapping or self.variable_mapping())
mapping = {self.prefixed(k): v for (k, v) in mapping.items()}
mapping = {k: v for (k, v) in mapping.items() if (k in self.layers)}
weight_value_pairs ... | -816,479,244,274,387,300 | 根据mapping从checkpoint加载权重 | bert4keras/models.py | load_weights_from_checkpoint | CurisZhou/bert4keras | python | def load_weights_from_checkpoint(self, checkpoint, mapping=None):
'\n '
mapping = (mapping or self.variable_mapping())
mapping = {self.prefixed(k): v for (k, v) in mapping.items()}
mapping = {k: v for (k, v) in mapping.items() if (k in self.layers)}
weight_value_pairs = []
for (layer, var... |
def save_weights_as_checkpoint(self, filename, mapping=None, dtype=None):
'根据mapping将权重保存为checkpoint格式\n '
mapping = (mapping or self.variable_mapping())
mapping = {self.prefixed(k): v for (k, v) in mapping.items()}
mapping = {k: v for (k, v) in mapping.items() if (k in self.layers)}
with tf.... | 6,964,417,971,275,611,000 | 根据mapping将权重保存为checkpoint格式 | bert4keras/models.py | save_weights_as_checkpoint | CurisZhou/bert4keras | python | def save_weights_as_checkpoint(self, filename, mapping=None, dtype=None):
'\n '
mapping = (mapping or self.variable_mapping())
mapping = {self.prefixed(k): v for (k, v) in mapping.items()}
mapping = {k: v for (k, v) in mapping.items() if (k in self.layers)}
with tf.Graph().as_default():
... |
def compute_attention_bias(self, inputs=None):
'通过idxs序列的比较来得到对应的mask\n '
if (self.attention_bias is None):
def lm_mask(s):
seq_len = K.shape(s)[1]
idxs = K.arange(0, seq_len)
mask = (idxs[None, :] <= idxs[:, None])
mask = K.cast(mask, K.floatx())
... | 85,604,987,621,142,820 | 通过idxs序列的比较来得到对应的mask | bert4keras/models.py | compute_attention_bias | CurisZhou/bert4keras | python | def compute_attention_bias(self, inputs=None):
'\n '
if (self.attention_bias is None):
def lm_mask(s):
seq_len = K.shape(s)[1]
idxs = K.arange(0, seq_len)
mask = (idxs[None, :] <= idxs[:, None])
mask = K.cast(mask, K.floatx())
return ((... |
def compute_attention_bias(self, inputs=None):
'通过idxs序列的比较来得到对应的mask\n '
if (self.attention_bias is None):
def unilm_mask(s):
idxs = K.cumsum(s, axis=1)
mask = (idxs[:, None, :] <= idxs[:, :, None])
mask = K.cast(mask, K.floatx())
return ((- (1 - ... | 5,273,371,874,282,328,000 | 通过idxs序列的比较来得到对应的mask | bert4keras/models.py | compute_attention_bias | CurisZhou/bert4keras | python | def compute_attention_bias(self, inputs=None):
'\n '
if (self.attention_bias is None):
def unilm_mask(s):
idxs = K.cumsum(s, axis=1)
mask = (idxs[:, None, :] <= idxs[:, :, None])
mask = K.cast(mask, K.floatx())
return ((- (1 - mask[:, None])) * 100... |
def get_inputs(self):
'BERT的输入是token_ids和segment_ids\n (但允许自行传入位置id,以实现一些特殊需求)\n '
x_in = self.apply(layer=Input, shape=(self.sequence_length,), name='Input-Token')
inputs = [x_in]
if (self.segment_vocab_size > 0):
s_in = self.apply(layer=Input, shape=(self.sequence_length,), name=... | 7,269,396,549,803,590,000 | BERT的输入是token_ids和segment_ids
(但允许自行传入位置id,以实现一些特殊需求) | bert4keras/models.py | get_inputs | CurisZhou/bert4keras | python | def get_inputs(self):
'BERT的输入是token_ids和segment_ids\n (但允许自行传入位置id,以实现一些特殊需求)\n '
x_in = self.apply(layer=Input, shape=(self.sequence_length,), name='Input-Token')
inputs = [x_in]
if (self.segment_vocab_size > 0):
s_in = self.apply(layer=Input, shape=(self.sequence_length,), name=... |
def apply_embeddings(self, inputs):
'BERT的embedding是token、position、segment三者embedding之和\n '
inputs = inputs[:]
x = inputs.pop(0)
if (self.segment_vocab_size > 0):
s = inputs.pop(0)
if self.custom_position_ids:
p = inputs.pop(0)
else:
p = None
z = self.layer_nor... | 1,239,644,505,264,093,200 | BERT的embedding是token、position、segment三者embedding之和 | bert4keras/models.py | apply_embeddings | CurisZhou/bert4keras | python | def apply_embeddings(self, inputs):
'\n '
inputs = inputs[:]
x = inputs.pop(0)
if (self.segment_vocab_size > 0):
s = inputs.pop(0)
if self.custom_position_ids:
p = inputs.pop(0)
else:
p = None
z = self.layer_norm_conds[0]
x = self.apply(inputs=x, layer=Embe... |
def apply_main_layers(self, inputs, index):
'BERT的主体是基于Self-Attention的模块\n 顺序:Att --> Add --> LN --> FFN --> Add --> LN\n '
x = inputs
z = self.layer_norm_conds[0]
attention_name = ('Transformer-%d-MultiHeadSelfAttention' % index)
feed_forward_name = ('Transformer-%d-FeedForward' % ind... | 2,721,950,488,057,795,000 | BERT的主体是基于Self-Attention的模块
顺序:Att --> Add --> LN --> FFN --> Add --> LN | bert4keras/models.py | apply_main_layers | CurisZhou/bert4keras | python | def apply_main_layers(self, inputs, index):
'BERT的主体是基于Self-Attention的模块\n 顺序:Att --> Add --> LN --> FFN --> Add --> LN\n '
x = inputs
z = self.layer_norm_conds[0]
attention_name = ('Transformer-%d-MultiHeadSelfAttention' % index)
feed_forward_name = ('Transformer-%d-FeedForward' % ind... |
def apply_final_layers(self, inputs):
'根据剩余参数决定输出\n '
x = inputs
z = self.layer_norm_conds[0]
outputs = [x]
if self.with_pool:
x = outputs[0]
x = self.apply(inputs=x, layer=Lambda, function=(lambda x: x[:, 0]), name='Pooler')
pool_activation = ('tanh' if (self.with_poo... | -7,915,576,084,156,456,000 | 根据剩余参数决定输出 | bert4keras/models.py | apply_final_layers | CurisZhou/bert4keras | python | def apply_final_layers(self, inputs):
'\n '
x = inputs
z = self.layer_norm_conds[0]
outputs = [x]
if self.with_pool:
x = outputs[0]
x = self.apply(inputs=x, layer=Lambda, function=(lambda x: x[:, 0]), name='Pooler')
pool_activation = ('tanh' if (self.with_pool is True)... |
def load_variable(self, checkpoint, name):
'加载单个变量的函数\n '
variable = super(BERT, self).load_variable(checkpoint, name)
if (name in ['bert/embeddings/word_embeddings', 'cls/predictions/output_bias']):
return self.load_embeddings(variable)
elif (name == 'cls/seq_relationship/output_weights'... | -4,583,431,683,787,596,300 | 加载单个变量的函数 | bert4keras/models.py | load_variable | CurisZhou/bert4keras | python | def load_variable(self, checkpoint, name):
'\n '
variable = super(BERT, self).load_variable(checkpoint, name)
if (name in ['bert/embeddings/word_embeddings', 'cls/predictions/output_bias']):
return self.load_embeddings(variable)
elif (name == 'cls/seq_relationship/output_weights'):
... |
def create_variable(self, name, value, dtype=None):
'在tensorflow中创建一个变量\n '
if (name == 'cls/seq_relationship/output_weights'):
value = value.T
return super(BERT, self).create_variable(name, value, dtype) | 9,075,869,065,190,741,000 | 在tensorflow中创建一个变量 | bert4keras/models.py | create_variable | CurisZhou/bert4keras | python | def create_variable(self, name, value, dtype=None):
'\n '
if (name == 'cls/seq_relationship/output_weights'):
value = value.T
return super(BERT, self).create_variable(name, value, dtype) |
def variable_mapping(self):
'映射到官方BERT权重格式\n '
mapping = {'Embedding-Token': ['bert/embeddings/word_embeddings'], 'Embedding-Segment': ['bert/embeddings/token_type_embeddings'], 'Embedding-Position': ['bert/embeddings/position_embeddings'], 'Embedding-Norm': ['bert/embeddings/LayerNorm/beta', 'bert/embed... | -1,916,485,818,333,458,000 | 映射到官方BERT权重格式 | bert4keras/models.py | variable_mapping | CurisZhou/bert4keras | python | def variable_mapping(self):
'\n '
mapping = {'Embedding-Token': ['bert/embeddings/word_embeddings'], 'Embedding-Segment': ['bert/embeddings/token_type_embeddings'], 'Embedding-Position': ['bert/embeddings/position_embeddings'], 'Embedding-Norm': ['bert/embeddings/LayerNorm/beta', 'bert/embeddings/LayerNo... |
def apply_main_layers(self, inputs, index):
'ALBERT的主体是基于Self-Attention的模块\n 顺序:Att --> Add --> LN --> FFN --> Add --> LN\n '
x = inputs
z = self.layer_norm_conds[0]
attention_name = 'Transformer-MultiHeadSelfAttention'
feed_forward_name = 'Transformer-FeedForward'
attention_mask =... | 3,918,039,020,763,709,000 | ALBERT的主体是基于Self-Attention的模块
顺序:Att --> Add --> LN --> FFN --> Add --> LN | bert4keras/models.py | apply_main_layers | CurisZhou/bert4keras | python | def apply_main_layers(self, inputs, index):
'ALBERT的主体是基于Self-Attention的模块\n 顺序:Att --> Add --> LN --> FFN --> Add --> LN\n '
x = inputs
z = self.layer_norm_conds[0]
attention_name = 'Transformer-MultiHeadSelfAttention'
feed_forward_name = 'Transformer-FeedForward'
attention_mask =... |
def variable_mapping(self):
'映射到官方ALBERT权重格式\n '
mapping = super(ALBERT, self).variable_mapping()
prefix = 'bert/encoder/transformer/group_0/inner_group_0/'
mapping.update({'Transformer-MultiHeadSelfAttention': [(prefix + 'attention_1/self/query/kernel'), (prefix + 'attention_1/self/query/bias'),... | 336,771,692,772,204,350 | 映射到官方ALBERT权重格式 | bert4keras/models.py | variable_mapping | CurisZhou/bert4keras | python | def variable_mapping(self):
'\n '
mapping = super(ALBERT, self).variable_mapping()
prefix = 'bert/encoder/transformer/group_0/inner_group_0/'
mapping.update({'Transformer-MultiHeadSelfAttention': [(prefix + 'attention_1/self/query/kernel'), (prefix + 'attention_1/self/query/bias'), (prefix + 'att... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.