本文整理汇总了Python中datasets.load_data方法的典型用法代码示例。如果您正苦于以下问题:Python datasets.load_data方法的具体用法?Python datasets.load_data怎么用?Python datasets.load_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类datasets
的用法示例。
在下文中一共展示了datasets.load_data方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import load_data [as 别名]
def main():
# Parse hyperparams
hparams = rebar.default_hparams
hparams.parse(FLAGS.hparams)
print(hparams.values())
train_xs, valid_xs, test_xs = datasets.load_data(hparams)
mean_xs = np.mean(train_xs, axis=0) # Compute mean centering on training
training_steps = 2000000
model = getattr(rebar, hparams.model)
sbn = model(hparams, mean_xs=mean_xs)
scores = train(sbn, train_xs, valid_xs, test_xs,
training_steps=training_steps, debug=False)
示例2: _get_data_and_model
# 需要导入模块: import datasets [as 别名]
# 或者: from datasets import load_data [as 别名]
def _get_data_and_model(args):
# prepare dataset
if args.method in ['FcDEC', 'FcIDEC', 'FcDEC-DA', 'FcIDEC-DA']:
x, y = load_data(args.dataset)
elif args.method in ['ConvDEC', 'ConvIDEC', 'ConvDEC-DA', 'ConvIDEC-DA']:
x, y = load_data_conv(args.dataset)
else:
raise ValueError("Invalid value for method, which can only be in ['FcDEC', 'FcIDEC', 'ConvDEC', 'ConvIDEC', "
"'FcDEC-DA', 'FcIDEC-DA', 'ConvDEC-DA', 'ConvIDEC-DA']")
# prepare optimizer
if args.optimizer in ['sgd', 'SGD']:
optimizer = SGD(args.lr, 0.9)
else:
optimizer = Adam()
# prepare the model
n_clusters = len(np.unique(y))
if 'FcDEC' in args.method:
model = FcDEC(dims=[x.shape[-1], 500, 500, 2000, 10], n_clusters=n_clusters)
model.compile(optimizer=optimizer, loss='kld')
elif 'FcIDEC' in args.method:
model = FcIDEC(dims=[x.shape[-1], 500, 500, 2000, 10], n_clusters=n_clusters)
model.compile(optimizer=optimizer, loss=['kld', 'mse'], loss_weights=[0.1, 1.0])
elif 'ConvDEC' in args.method:
model = ConvDEC(input_shape=x.shape[1:], filters=[32, 64, 128, 10], n_clusters=n_clusters)
model.compile(optimizer=optimizer, loss='kld')
elif 'ConvIDEC' in args.method:
model = ConvIDEC(input_shape=x.shape[1:], filters=[32, 64, 128, 10], n_clusters=n_clusters)
model.compile(optimizer=optimizer, loss=['kld', 'mse'], loss_weights=[0.1, 1.0])
else:
raise ValueError("Invalid value for method, which can only be in ['FcDEC', 'FcIDEC', 'ConvDEC', 'ConvIDEC', "
"'FcDEC-DA', 'FcIDEC-DA', 'ConvDEC-DA', 'ConvIDEC-DA']")
# if -DA method, we'll force aug_pretrain and aug_cluster is True
if '-DA' in args.method:
args.aug_pretrain = True
args.aug_cluster = True
return (x, y), model