Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
resume_epoch = Int(0, config=True, help="Epoch to resume (requires using also '--resume_path'.")
coco_path = Unicode(u"/tmp/aa/coco", config=True, help="path to local coco dataset path")
init_inception = Bool(True, config=True, help="Initialize the inception networks using the paper's base network.")
#
# Network hyper parameters
#
base_network_name = Unicode("Inception3", config=True, help="Name of base network to use.")
avgpool_kernel = Int(10, config=True,
help="Size of the last avgpool layer in the Resnet. Should match the cropsize.")
classifier_name = Unicode("Inception3Classifier", config=True, help="Name of classifier to use.")
sets_network_name = Unicode("SetOpsResModule", config=True, help="Name of setops module to use.")
sets_block_name = Unicode("SetopResBlock_v1", config=True, help="Name of setops network to use.")
sets_basic_block_name = Unicode("SetopResBasicBlock", config=True,
help="Name of the basic setops block to use (where applicable).")
ops_layer_num = Int(1, config=True, help="Ops Module layers num.")
ops_latent_dim = Int(1024, config=True, help="Ops Module inner latent dim.")
setops_dropout = Float(0, config=True, help="Dropout ratio of setops module.")
crop_size = Int(299, config=True, help="Size of input crop (Resnet 224, inception 299).")
scale_size = Int(350, config=True, help="Size of input scale for data augmentation. default: 350")
paper_reproduce = Bool(False, config=True, help="Use paper reproduction settings. default: False")
discriminator_name = Unicode("AmitDiscriminator", config=True,
help="Name of discriminator (unseen classifier) to use. default: AmitDiscriminator")
embedding_dim = Int(2048, config=True, help="Dimensionality of the LaSO space. default:2048")
classifier_latent_dim = Int(2048, config=True, help="Dimensionality of the classifier latent space. default:2048")
def run(self):
#
# Setup the model
#
base_model, classifier, setops_model = self.setup_model()
# local
import kale.batch_jobs
# TODO - Convert print statements to logging statements
# TODO - update all instances of default arguments set to a mutable e.g.; [], {}
class WorkerPool(traitlets.HasTraits):
"""Pool of workers which can execute jobs."""
futures = traitlets.List()
workers = traitlets.List()
wf_executor = traitlets.Unicode()
name = traitlets.Unicode()
location = traitlets.Unicode()
num_workers = traitlets.Int()
def __init__(self, name, num_workers, fwconfig=None, location='localhost', wf_executor='fireworks'):
super().__init__()
self.futures = []
self.workers = []
self.wf_executor = wf_executor
self.name = name
self.fwconfig = fwconfig
self.location = location
self.log_area = ipw.Output()
self._add_workers(num_workers)
if wf_executor == 'fireworks':
access_key_id=self.aws_access_key_id,
secret_access_key=self.aws_secret_access_key,
pre_auth_headers=self.pre_auth_headers,
)
class FargateSpawner(Spawner):
aws_region = Unicode(config=True)
aws_ecs_host = Unicode(config=True)
task_role_arn = Unicode(config=True)
task_cluster_name = Unicode(config=True)
task_container_name = Unicode(config=True)
task_definition_arn = Unicode(config=True)
task_security_groups = List(trait=Unicode, config=True)
task_subnets = List(trait=Unicode, config=True)
notebook_port = Int(config=True)
notebook_scheme = Unicode(config=True)
notebook_args = List(trait=Unicode, config=True)
authentication_class = Type(FargateSpawnerAuthentication, config=True)
authentication = Instance(FargateSpawnerAuthentication)
@default('authentication')
def _default_authentication(self):
return self.authentication_class(parent=self)
task_arn = Unicode('')
# We mostly are able to call the AWS API to determine status. However, when we yield the
# event loop to create the task, if there is a poll before the creation is complete,
# we must behave as though we are running/starting, but we have no IDs to use with which
# to check the task.
@validate('map_v_options')
def _validate_map_v_options(self, proposal):
self.size = proposal['value']['size'] if 'size' in proposal['value']else 5
self.global_alpha = proposal['value']['globalAlpha'] if 'globalAlpha' in proposal['value'] else 1
self.fill_style = proposal['value']['fillStyle'] if 'fillStyle' in proposal['value'] else'#3732FA'
self.shadow_color = proposal['value']['shadowColor'] if 'shadowColor' in proposal['value'] else'#FFFA32'
self.shadow_blur = proposal['value']['shadowBlur'] if 'shadowBlur' in proposal['value'] else 35
# self.line_width = proposal['value']['lineWidth'] if 'lineWidth' in proposal['value'] else 4
return proposal['value']
size = Int().tag(sync=True)
global_alpha = Float().tag(sync=True)
fill_style = Unicode('').tag(sync=True)
shadow_color = Unicode('').tag(sync=True)
shadow_blur = Int().tag(sync=True)
# line_width = Int(4).tag(sync=True)
def interact(self):
sizeslider = IntSlider(value=self.size,
min=0,
max=100,
step=1,
description='大小:',
disabled=False,
continuous_update=False,
orientation='horizontal',
readout=True,
readout_format='d',
layout=Layout(width="350px"))
link((sizeslider, 'value'), (self, 'size'))
# Traits
#-------------------------------------------------------------------------
_model_module = Unicode(None, allow_none=True, help="""A requirejs module name
in which to find _model_name. If empty, look in the global registry.""")
_model_name = Unicode('WidgetModel', help="""Name of the backbone model
registered in the front-end to create and sync this widget with.""")
_view_module = Unicode(help="""A requirejs module in which to find _view_name.
If empty, look in the global registry.""", sync=True)
_view_name = Unicode(None, allow_none=True, help="""Default view registered in the front-end
to use to represent the widget.""", sync=True)
comm = Instance('ipython_kernel.comm.Comm', allow_none=True)
msg_throttle = Int(3, sync=True, help="""Maximum number of msgs the
front-end can send before receiving an idle msg from the back-end.""")
version = Int(0, sync=True, help="""Widget's version""")
keys = List()
def _keys_default(self):
return [name for name in self.traits(sync=True)]
_property_lock = Tuple((None, None))
_send_state_lock = Int(0)
_states_to_send = Set()
_display_callbacks = Instance(CallbackDispatcher, ())
_msg_callbacks = Instance(CallbackDispatcher, ())
#-------------------------------------------------------------------------
# (Con/de)structor
#-------------------------------------------------------------------------
def __init__(self, **kwargs):
"""Public constructor"""
self._model_id = kwargs.pop('model_id', None)
for b in range(len(D)):
for q in range(len(D[b])):
if D[b][q] > 0:
mask[b][q] = 1
return mask
class DAZER(BaseNN):
#params of zeroshot document filtering model
embedding_size = Int(300, help="embedding dimension").tag(config=True)
vocabulary_size = Int(2000000, help="vocabulary size").tag(config=True)
kernal_width = Int(5, help='kernal width').tag(config=True)
kernal_num = Int(50, help='number of kernal').tag(config=True)
regular_term = Float(0.01, help='param for controlling wight of L2 loss').tag(config=True)
maxpooling_num = Int(3, help='number of k-maxpooling').tag(config=True)
decoder_mlp1_num = Int(75, help='number of hidden units of first mlp in relevance aggregation part').tag(config=True)
decoder_mlp2_num = Int(1, help='number of hidden units of second mlp in relevance aggregation part').tag(config=True)
emb_in = Unicode('None', help="initial embedding. Terms should be hashed to ids.").tag(config=True)
model_learning_rate = Float(0.001, help="learning rate of model").tag(config=True)
adv_learning_rate = Float(0.001, help='learning rate of adv classifier').tag(config=True)
epsilon = Float(0.00001, help="Epsilon for Adam").tag(config=True)
label_dict_path = Unicode('None', help='label dict path').tag(config=True)
word2id_path = Unicode('None', help='word2id path').tag(config=True)
train_class_num = Int(16, help='num of class in training data').tag(config=True)
adv_term = Float(0.2, help='regular term of adversrial loss').tag(config=True)
zsl_num = Int(1, help='num of zeroshot label').tag(config=True)
zsl_type = Int(1, help='type of zeroshot label setting').tag(config=True)
def __init__(self, **kwargs):
#init the DAZER model
super(DAZER, self).__init__(**kwargs)
print ("trying to load initial embeddings from: ", self.emb_in)
# Specification of the basemap
basemap = Dict(default_value=dict(
url='https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
max_zoom=19,
attribution='Map data (c) <a href="https://openstreetmap.org">OpenStreetMap</a> contributors'
)).tag(sync=True, o=True)
modisdate = Unicode('yesterday').tag(sync=True)
# Interaction options
dragging = Bool(True).tag(sync=True, o=True)
touch_zoom = Bool(True).tag(sync=True, o=True)
scroll_wheel_zoom = Bool(False).tag(sync=True, o=True)
double_click_zoom = Bool(True).tag(sync=True, o=True)
box_zoom = Bool(True).tag(sync=True, o=True)
tap = Bool(True).tag(sync=True, o=True)
tap_tolerance = Int(15).tag(sync=True, o=True)
world_copy_jump = Bool(False).tag(sync=True, o=True)
close_popup_on_click = Bool(True).tag(sync=True, o=True)
bounce_at_zoom_limits = Bool(True).tag(sync=True, o=True)
keyboard = Bool(True).tag(sync=True, o=True)
keyboard_pan_offset = Int(80).tag(sync=True, o=True)
keyboard_zoom_offset = Int(1).tag(sync=True, o=True)
inertia = Bool(True).tag(sync=True, o=True)
inertia_deceleration = Int(3000).tag(sync=True, o=True)
inertia_max_speed = Int(1500).tag(sync=True, o=True)
# inertia_threshold = Int(?, o=True).tag(sync=True)
# fade_animation = Bool(?).tag(sync=True, o=True)
# zoom_animation = Bool(?).tag(sync=True, o=True)
zoom_animation_threshold = Int(4).tag(sync=True, o=True)
# marker_zoom_animation = Bool(?).tag(sync=True, o=True)
fullscreen = Bool(False).tag(sync=True, o=True)
total_samples = Int(default_value=5000000)
reduce_lr_flag = Bool(default_value=False)
# regularization params for embedding layer: l1 for mag/sparse, l2 for dir
l2_lambda = Float(default_value=0.00001)
l1_lambda = Float(default_value=0.0000001)
dropout_p = Float(default_value=0)
use_magdir = Bool(default_value=True)
# params for TextEmbeddingConv
kernel_width = Int(default_value=5)
stride = Int(default_value=2)
# params for TextEmbeddingConv2
filters = Int(default_value=100) # default in the paper
max_kernel_size = Int(default_value=5) # we use 2, 3, 4, 5. paper uses 3, 4, 5
# dense layers
dense_config = Unicode(default_value='20,20')
num_ann_nbrs_to_fetch = Int(default_value=100)
num_candidates_to_rank = Int(default_value=100) # No. of candidates to fetch from ANN at eval time
extend_candidate_citations = Bool(default_value=True) # Whether to include citations of ANN
# similar docs as possible candidates or not
use_pretrained = Bool(default_value=False)
num_oov_buckets = 100 # for hashing out of vocab terms
dense_dim_pretrained = 300 # just a fact - don't change
oov_term_prefix = '#OOV_'
subset_vocab_to_training = False
# minimum number of papers for authors/venues/keyphrases to get an embedding.
peak_index,
self.window_width.tel[telid],
self.window_shift.tel[telid],
self.sampling_rate[telid],
)
charge *= self._calculate_correction(telid=telid)[selected_gain_channel]
return charge, peak_time
class BaselineSubtractedNeighborPeakWindowSum(NeighborPeakWindowSum):
"""
Extractor that first subtracts the baseline before summing in a
window about the peak defined by the wavefroms in neighboring pixels.
"""
baseline_start = Int(0, help="Start sample for baseline estimation").tag(
config=True
)
baseline_end = Int(10, help="End sample for baseline estimation").tag(config=True)
def __call__(self, waveforms, telid, selected_gain_channel):
baseline_corrected = subtract_baseline(
waveforms, self.baseline_start, self.baseline_end
)
return super().__call__(baseline_corrected, telid, selected_gain_channel)
class TwoPassWindowSum(ImageExtractor):
"""Extractor based on [1]_ which integrates the waveform a second time using
a time-gradient linear fit. This is in particular the version implemented
in the CTA-MARS analysis pipeline [2]_.
class LDAPAuthenticator(Authenticator):
"""
LDAP Authenticator for Jupyterhub
"""
server_hosts = Union(
[List(), Unicode()],
config=True,
help="""
List of Names, IPs, or the complete URLs in the scheme://host:port
format of the server (required).
"""
)
server_port = Int(
allow_none=True,
default_value=None,
config=True,
help="""
The port where the LDAP server is listening. Typically 389, for a
cleartext connection, and 636 for a secured connection (defaults to None).
"""
)
server_use_ssl = Bool(
default_value=False,
config=True,
help="""
Boolean specifying if the connection is on a secure port (defaults to False).
"""
)