Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
val_list = [s.strip() for s in value.split(",")]
return set(val_list).issubset(valid_superset)
return validate
class Object2Vec(AmazonAlgorithmEstimatorBase):
"""Placeholder docstring"""
repo_name = "object2vec"
repo_version = 1
MINI_BATCH_SIZE = 32
enc_dim = hp("enc_dim", (ge(4), le(10000)), "An integer in [4, 10000]", int)
mini_batch_size = hp("mini_batch_size", (ge(1), le(10000)), "An integer in [1, 10000]", int)
epochs = hp("epochs", (ge(1), le(100)), "An integer in [1, 100]", int)
early_stopping_patience = hp(
"early_stopping_patience", (ge(1), le(5)), "An integer in [1, 5]", int
)
early_stopping_tolerance = hp(
"early_stopping_tolerance", (ge(1e-06), le(0.1)), "A float in [1e-06, 0.1]", float
)
dropout = hp("dropout", (ge(0.0), le(1.0)), "A float in [0.0, 1.0]", float)
weight_decay = hp("weight_decay", (ge(0.0), le(10000.0)), "A float in [0.0, 10000.0]", float)
bucket_width = hp("bucket_width", (ge(0), le(100)), "An integer in [0, 100]", int)
num_classes = hp("num_classes", (ge(2), le(30)), "An integer in [2, 30]", int)
mlp_layers = hp("mlp_layers", (ge(1), le(10)), "An integer in [1, 10]", int)
mlp_dim = hp("mlp_dim", (ge(2), le(10000)), "An integer in [2, 10000]", int)
mlp_activation = hp(
"mlp_activation", isin("tanh", "relu", "linear"), 'One of "tanh", "relu", "linear"', str
)
output_layer = hp(
enc_dim = hp("enc_dim", (ge(4), le(10000)), "An integer in [4, 10000]", int)
mini_batch_size = hp("mini_batch_size", (ge(1), le(10000)), "An integer in [1, 10000]", int)
epochs = hp("epochs", (ge(1), le(100)), "An integer in [1, 100]", int)
early_stopping_patience = hp(
"early_stopping_patience", (ge(1), le(5)), "An integer in [1, 5]", int
)
early_stopping_tolerance = hp(
"early_stopping_tolerance", (ge(1e-06), le(0.1)), "A float in [1e-06, 0.1]", float
)
dropout = hp("dropout", (ge(0.0), le(1.0)), "A float in [0.0, 1.0]", float)
weight_decay = hp("weight_decay", (ge(0.0), le(10000.0)), "A float in [0.0, 10000.0]", float)
bucket_width = hp("bucket_width", (ge(0), le(100)), "An integer in [0, 100]", int)
num_classes = hp("num_classes", (ge(2), le(30)), "An integer in [2, 30]", int)
mlp_layers = hp("mlp_layers", (ge(1), le(10)), "An integer in [1, 10]", int)
mlp_dim = hp("mlp_dim", (ge(2), le(10000)), "An integer in [2, 10000]", int)
mlp_activation = hp(
"mlp_activation", isin("tanh", "relu", "linear"), 'One of "tanh", "relu", "linear"', str
)
output_layer = hp(
"output_layer",
isin("softmax", "mean_squared_error"),
'One of "softmax", "mean_squared_error"',
str,
)
optimizer = hp(
"optimizer",
isin("adagrad", "adam", "rmsprop", "sgd", "adadelta"),
'One of "adagrad", "adam", "rmsprop", "sgd", "adadelta"',
str,
)
learning_rate = hp("learning_rate", (ge(1e-06), le(1.0)), "A float in [1e-06, 1.0]", float)
from sagemaker.predictor import RealTimePredictor
from sagemaker.model import Model
from sagemaker.session import Session
from sagemaker.vpc_utils import VPC_CONFIG_DEFAULT
class KMeans(AmazonAlgorithmEstimatorBase):
"""Placeholder docstring"""
repo_name = "kmeans"
repo_version = 1
k = hp("k", gt(1), "An integer greater-than 1", int)
init_method = hp("init_method", isin("random", "kmeans++"), 'One of "random", "kmeans++"', str)
max_iterations = hp("local_lloyd_max_iter", gt(0), "An integer greater-than 0", int)
tol = hp("local_lloyd_tol", (ge(0), le(1)), "An float in [0, 1]", float)
num_trials = hp("local_lloyd_num_trials", gt(0), "An integer greater-than 0", int)
local_init_method = hp(
"local_lloyd_init_method", isin("random", "kmeans++"), 'One of "random", "kmeans++"', str
)
half_life_time_size = hp(
"half_life_time_size", ge(0), "An integer greater-than-or-equal-to 0", int
)
epochs = hp("epochs", gt(0), "An integer greater-than 0", int)
center_factor = hp("extra_center_factor", gt(0), "An integer greater-than 0", int)
eval_metrics = hp(
name="eval_metrics",
validation_message='A comma separated list of "msd" or "ssd"',
data_type=list,
)
def __init__(
class KMeans(AmazonAlgorithmEstimatorBase):
"""Placeholder docstring"""
repo_name = "kmeans"
repo_version = 1
k = hp("k", gt(1), "An integer greater-than 1", int)
init_method = hp("init_method", isin("random", "kmeans++"), 'One of "random", "kmeans++"', str)
max_iterations = hp("local_lloyd_max_iter", gt(0), "An integer greater-than 0", int)
tol = hp("local_lloyd_tol", (ge(0), le(1)), "An float in [0, 1]", float)
num_trials = hp("local_lloyd_num_trials", gt(0), "An integer greater-than 0", int)
local_init_method = hp(
"local_lloyd_init_method", isin("random", "kmeans++"), 'One of "random", "kmeans++"', str
)
half_life_time_size = hp(
"half_life_time_size", ge(0), "An integer greater-than-or-equal-to 0", int
)
epochs = hp("epochs", gt(0), "An integer greater-than 0", int)
center_factor = hp("extra_center_factor", gt(0), "An integer greater-than 0", int)
eval_metrics = hp(
name="eval_metrics",
validation_message='A comma separated list of "msd" or "ssd"',
data_type=list,
)
def __init__(
self,
role,
train_instance_count,
train_instance_type,
k,
dimension_reduction_type = hp(
"dimension_reduction_type", isin("sign", "fjlt"), 'One of "sign" or "fjlt"', str
)
index_metric = hp(
"index_metric",
isin("COSINE", "INNER_PRODUCT", "L2"),
'One of "COSINE", "INNER_PRODUCT", "L2"',
str,
)
index_type = hp(
"index_type",
isin("faiss.Flat", "faiss.IVFFlat", "faiss.IVFPQ"),
'One of "faiss.Flat", "faiss.IVFFlat", "faiss.IVFPQ"',
str,
)
faiss_index_ivf_nlists = hp(
"faiss_index_ivf_nlists", (), '"auto" or an integer greater than 0', str
)
faiss_index_pq_m = hp("faiss_index_pq_m", (ge(1)), "An integer greater than 0", int)
def __init__(
self,
role,
train_instance_count,
train_instance_type,
k,
sample_size,
predictor_type,
dimension_reduction_type=None,
dimension_reduction_target=None,
index_type=None,
index_metric=None,
repo_name = "factorization-machines"
repo_version = 1
num_factors = hp("num_factors", gt(0), "An integer greater than zero", int)
predictor_type = hp(
"predictor_type",
isin("binary_classifier", "regressor"),
'Value "binary_classifier" or "regressor"',
str,
)
epochs = hp("epochs", gt(0), "An integer greater than 0", int)
clip_gradient = hp("clip_gradient", (), "A float value", float)
eps = hp("eps", (), "A float value", float)
rescale_grad = hp("rescale_grad", (), "A float value", float)
bias_lr = hp("bias_lr", ge(0), "A non-negative float", float)
linear_lr = hp("linear_lr", ge(0), "A non-negative float", float)
factors_lr = hp("factors_lr", ge(0), "A non-negative float", float)
bias_wd = hp("bias_wd", ge(0), "A non-negative float", float)
linear_wd = hp("linear_wd", ge(0), "A non-negative float", float)
factors_wd = hp("factors_wd", ge(0), "A non-negative float", float)
bias_init_method = hp(
"bias_init_method",
isin("normal", "uniform", "constant"),
'Value "normal", "uniform" or "constant"',
str,
)
bias_init_scale = hp("bias_init_scale", ge(0), "A non-negative float", float)
bias_init_sigma = hp("bias_init_sigma", ge(0), "A non-negative float", float)
bias_init_value = hp("bias_init_value", (), "A float value", float)
linear_init_method = hp(
"linear_init_method",
isin("normal", "uniform", "constant"),
"squared_loss",
"absolute_loss",
"hinge_loss",
"eps_insensitive_squared_loss",
"eps_insensitive_absolute_loss",
"quantile_loss",
"huber_loss",
"softmax_loss",
"auto",
),
'"logistic", "squared_loss", "absolute_loss", "hinge_loss", "eps_insensitive_squared_loss",'
' "eps_insensitive_absolute_loss", "quantile_loss", "huber_loss", "softmax_loss" or "auto"',
str,
)
wd = hp("wd", ge(0), "A float greater-than or equal to 0", float)
l1 = hp("l1", ge(0), "A float greater-than or equal to 0", float)
momentum = hp("momentum", (ge(0), lt(1)), "A float in [0,1)", float)
learning_rate = hp("learning_rate", gt(0), "A float greater-than 0", float)
beta_1 = hp("beta_1", (ge(0), lt(1)), "A float in [0,1)", float)
beta_2 = hp("beta_2", (ge(0), lt(1)), "A float in [0,1)", float)
bias_lr_mult = hp("bias_lr_mult", gt(0), "A float greater-than 0", float)
bias_wd_mult = hp("bias_wd_mult", ge(0), "A float greater-than or equal to 0", float)
use_lr_scheduler = hp("use_lr_scheduler", (), "A boolean", bool)
lr_scheduler_step = hp("lr_scheduler_step", gt(0), "An integer greater-than 0", int)
lr_scheduler_factor = hp("lr_scheduler_factor", (gt(0), lt(1)), "A float in (0,1)", float)
lr_scheduler_minimum_lr = hp("lr_scheduler_minimum_lr", gt(0), "A float greater-than 0", float)
normalize_data = hp("normalize_data", (), "A boolean", bool)
normalize_label = hp("normalize_label", (), "A boolean", bool)
unbias_data = hp("unbias_data", (), "A boolean", bool)
unbias_label = hp("unbias_label", (), "A boolean", bool)
num_point_for_scaler = hp("num_point_for_scaler", gt(0), "An integer greater-than 0", int)
margin = hp("margin", ge(0), "A float greater-than or equal to 0", float)
"encoder_layers_activation",
isin("sigmoid", "tanh", "relu"),
'One of "sigmoid", "tanh" or "relu"',
str,
)
optimizer = hp(
"optimizer",
isin("adagrad", "adam", "rmsprop", "sgd", "adadelta"),
'One of "adagrad", "adam", "rmsprop", "sgd" and "adadelta"',
str,
)
tolerance = hp("tolerance", (ge(1e-6), le(0.1)), "A float in [1e-6, 0.1]", float)
num_patience_epochs = hp("num_patience_epochs", (ge(1), le(10)), "An integer in [1, 10]", int)
batch_norm = hp(name="batch_norm", validation_message="Value must be a boolean", data_type=bool)
rescale_gradient = hp("rescale_gradient", (ge(1e-3), le(1.0)), "A float in [1e-3, 1.0]", float)
clip_gradient = hp("clip_gradient", ge(1e-3), "A float greater equal to 1e-3", float)
weight_decay = hp("weight_decay", (ge(0.0), le(1.0)), "A float in [0.0, 1.0]", float)
learning_rate = hp("learning_rate", (ge(1e-6), le(1.0)), "A float in [1e-6, 1.0]", float)
def __init__(
self,
role,
train_instance_count,
train_instance_type,
num_topics,
encoder_layers=None,
epochs=None,
encoder_layers_activation=None,
optimizer=None,
tolerance=None,
num_patience_epochs=None,
batch_norm=None,
mlp_activation = hp(
"mlp_activation", isin("tanh", "relu", "linear"), 'One of "tanh", "relu", "linear"', str
)
output_layer = hp(
"output_layer",
isin("softmax", "mean_squared_error"),
'One of "softmax", "mean_squared_error"',
str,
)
optimizer = hp(
"optimizer",
isin("adagrad", "adam", "rmsprop", "sgd", "adadelta"),
'One of "adagrad", "adam", "rmsprop", "sgd", "adadelta"',
str,
)
learning_rate = hp("learning_rate", (ge(1e-06), le(1.0)), "A float in [1e-06, 1.0]", float)
negative_sampling_rate = hp(
"negative_sampling_rate", (ge(0), le(100)), "An integer in [0, 100]", int
)
comparator_list = hp(
"comparator_list",
_list_check_subset(["hadamard", "concat", "abs_diff"]),
'Comma-separated of hadamard, concat, abs_diff. E.g. "hadamard,abs_diff"',
str,
)
tied_token_embedding_weight = hp(
"tied_token_embedding_weight", (), "Either True or False", bool
)
token_embedding_storage_type = hp(
"token_embedding_storage_type",
isin("dense", "row_sparse"),
)
enc0_network = hp(
"enc0_network",
isin("hcnn", "bilstm", "pooled_embedding"),
'One of "hcnn", "bilstm", "pooled_embedding"',
str,
)
enc1_network = hp(
"enc1_network",
isin("hcnn", "bilstm", "pooled_embedding", "enc0"),
'One of "hcnn", "bilstm", "pooled_embedding", "enc0"',
str,
)
enc0_cnn_filter_width = hp("enc0_cnn_filter_width", (ge(1), le(9)), "An integer in [1, 9]", int)
enc1_cnn_filter_width = hp("enc1_cnn_filter_width", (ge(1), le(9)), "An integer in [1, 9]", int)
enc0_max_seq_len = hp("enc0_max_seq_len", (ge(1), le(5000)), "An integer in [1, 5000]", int)
enc1_max_seq_len = hp("enc1_max_seq_len", (ge(1), le(5000)), "An integer in [1, 5000]", int)
enc0_token_embedding_dim = hp(
"enc0_token_embedding_dim", (ge(2), le(1000)), "An integer in [2, 1000]", int
)
enc1_token_embedding_dim = hp(
"enc1_token_embedding_dim", (ge(2), le(1000)), "An integer in [2, 1000]", int
)
enc0_vocab_size = hp("enc0_vocab_size", (ge(2), le(3000000)), "An integer in [2, 3000000]", int)
enc1_vocab_size = hp("enc1_vocab_size", (ge(2), le(3000000)), "An integer in [2, 3000000]", int)
enc0_layers = hp("enc0_layers", (ge(1), le(4)), "An integer in [1, 4]", int)
enc1_layers = hp("enc1_layers", (ge(1), le(4)), "An integer in [1, 4]", int)
enc0_freeze_pretrained_embedding = hp(
"enc0_freeze_pretrained_embedding", (), "Either True or False", bool
)
enc1_freeze_pretrained_embedding = hp(