Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def add_feature_data(
feature,
dataset_df,
data,
metadata,
preprocessing_parameters
):
set_default_value(
feature['preprocessing'],
'in_memory',
preprocessing_parameters['in_memory']
)
set_default_value(
feature['preprocessing'],
'num_processes',
preprocessing_parameters['num_processes']
)
csv_path = None
if hasattr(dataset_df, 'csv'):
csv_path = os.path.dirname(os.path.abspath(dataset_df.csv))
num_images = len(dataset_df)
if num_images == 0:
raise ValueError('There are no images in the dataset provided.')
first_image_path = dataset_df[feature['name']][0]
if csv_path is None and not os.path.isabs(first_image_path):
raise ValueError('Image file paths must be absolute')
def populate_defaults(input_feature):
set_default_value(input_feature, 'tied_weights', None)
def populate_defaults(input_feature):
set_default_value(input_feature, 'tied_weights', None)
set_default_value(output_feature[LOSS],
'class_similarities_temperature', 0)
set_default_value(output_feature[LOSS], 'weight', 1)
if output_feature[LOSS]['type'] == 'sampled_softmax_cross_entropy':
set_default_value(output_feature[LOSS], 'sampler', 'log_uniform')
set_default_value(output_feature[LOSS], 'negative_samples', 25)
set_default_value(output_feature[LOSS], 'distortion', 0.75)
else:
set_default_value(output_feature[LOSS], 'sampler', None)
set_default_value(output_feature[LOSS], 'negative_samples', 0)
set_default_value(output_feature[LOSS], 'distortion', 1)
set_default_value(output_feature[LOSS], 'unique', False)
set_default_value(output_feature, 'decoder', 'generator')
if output_feature['decoder'] == 'tagger':
set_default_value(output_feature, 'reduce_input', None)
set_default_value(output_feature, 'dependencies', [])
set_default_value(output_feature, 'reduce_input', SUM)
set_default_value(output_feature, 'reduce_dependencies', SUM)
set_default_value(output_feature[LOSS], 'sampler', 'log_uniform')
set_default_value(output_feature[LOSS], 'negative_samples', 25)
set_default_value(output_feature[LOSS], 'distortion', 0.75)
else:
set_default_value(output_feature[LOSS], 'sampler', None)
set_default_value(output_feature[LOSS], 'negative_samples', 0)
set_default_value(output_feature[LOSS], 'distortion', 1)
set_default_value(output_feature[LOSS], 'unique', False)
set_default_value(output_feature, 'decoder', 'generator')
if output_feature['decoder'] == 'tagger':
set_default_value(output_feature, 'reduce_input', None)
set_default_value(output_feature, 'dependencies', [])
set_default_value(output_feature, 'reduce_input', SUM)
set_default_value(output_feature, 'reduce_dependencies', SUM)
def populate_defaults(output_feature):
set_default_value(
output_feature,
LOSS,
{'type': 'mean_absolute_error', 'weight': 1}
)
set_default_value(output_feature[LOSS], 'type', 'mean_absolute_error')
set_default_value(output_feature[LOSS], 'weight', 1)
set_default_value(output_feature, 'decoder', 'generator')
if output_feature['decoder'] == 'generator':
set_default_value(output_feature, 'cell_type', 'rnn')
set_default_value(output_feature, 'state_size', 256)
set_default_value(output_feature, 'embedding_size', 1)
set_default_value(output_feature, 'attention_mechanism', None)
if output_feature['attention_mechanism'] is not None:
set_default_value(output_feature, 'reduce_input', None)
set_default_value(output_feature, 'decoder', 'generator')
set_default_value(output_feature, 'decoder', 'generator')
set_default_value(output_feature, 'decoder', 'generator')
set_default_value(output_feature, 'decoder', 'generator')
if output_feature['decoder'] == 'tagger':
if 'reduce_input' not in output_feature:
output_feature['reduce_input'] = None
set_default_value(output_feature, 'dependencies', [])
set_default_value(output_feature, 'reduce_input', SUM)
set_default_value(output_feature, 'reduce_dependencies', SUM)
def populate_defaults(output_feature):
set_default_value(
output_feature,
LOSS,
{'type': 'mean_squared_error', 'weight': 1}
)
set_default_value(output_feature[LOSS], 'type', 'mean_squared_error')
set_default_value(output_feature[LOSS], 'weight', 1)
set_default_values(
output_feature,
{
'clip': None,
'dependencies': [],
'reduce_input': SUM,
'reduce_dependencies': SUM
}
def populate_defaults(output_feature):
set_default_value(output_feature, LOSS, {})
set_default_value(output_feature[LOSS], 'type', MEAN_SQUARED_ERROR)
set_default_value(output_feature[LOSS], 'weight', 1)
set_default_value(output_feature, 'reduce_input', None)
set_default_value(output_feature, 'reduce_dependencies', None)
set_default_value(output_feature, 'softmax', False)
set_default_value(output_feature, 'decoder', 'fc_stack')
set_default_value(output_feature, 'dependencies', [])
)
set_default_value(output_feature[LOSS], 'type', 'softmax_cross_entropy')
set_default_value(output_feature[LOSS], 'labels_smoothing', 0)
set_default_value(output_feature[LOSS], 'class_weights', 1)
set_default_value(output_feature[LOSS], 'robust_lambda', 0)
set_default_value(output_feature[LOSS], 'confidence_penalty', 0)
set_default_value(output_feature[LOSS],
'class_similarities_temperature', 0)
set_default_value(output_feature[LOSS], 'weight', 1)
if output_feature[LOSS]['type'] == 'sampled_softmax_cross_entropy':
set_default_value(output_feature[LOSS], 'sampler', 'log_uniform')
set_default_value(output_feature[LOSS], 'negative_samples', 25)
set_default_value(output_feature[LOSS], 'distortion', 0.75)
else:
set_default_value(output_feature[LOSS], 'sampler', None)
set_default_value(output_feature[LOSS], 'negative_samples', 0)
set_default_value(output_feature[LOSS], 'distortion', 1)
set_default_value(output_feature[LOSS], 'unique', False)
set_default_value(output_feature, 'decoder', 'generator')
if output_feature['decoder'] == 'tagger':
set_default_value(output_feature, 'reduce_input', None)
set_default_value(output_feature, 'dependencies', [])
set_default_value(output_feature, 'reduce_input', SUM)
set_default_value(output_feature, 'reduce_dependencies', SUM)
def populate_defaults(output_feature):
set_default_value(output_feature, LOSS, {'weight': 1, 'type': None})
set_default_value(output_feature[LOSS], 'weight', 1)
set_default_value(output_feature, 'threshold', 0.5)
set_default_value(output_feature, 'dependencies', [])
set_default_value(output_feature, 'reduce_input', SUM)
set_default_value(output_feature, 'reduce_dependencies', SUM)