本文整理匯總了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