本文整理汇总了Python中mlp.MLP.set_params方法的典型用法代码示例。如果您正苦于以下问题:Python MLP.set_params方法的具体用法?Python MLP.set_params怎么用?Python MLP.set_params使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mlp.MLP
的用法示例。
在下文中一共展示了MLP.set_params方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: OrderedDict
# 需要导入模块: from mlp import MLP [as 别名]
# 或者: from mlp.MLP import set_params [as 别名]
num_trials = 10
n_tried = 0
best_valid, best_test, best_conf = None, None, None
while n_tried < num_trials:
# choose randomly a configuration for the paramters
try_this = [np.random.randint(len(p)) for p in params.values()]
try_params = OrderedDict([(k, v[try_this[i]]) for i, (k, v) in enumerate(params.items())])
model = MLP(
n_classes=10,
optim='adagrad',
n_inputs=train_x.shape[1],
activation='relu',
layers=[256, 128])
model.set_params(**try_params)
fname = os.path.join(dest_dir,
'mlp_{}_{}_l{}_lr{}_m{}_di{}_dh{}.npz'.format(
model.optimization,
model.activation,
'-'.join(map(str, model.layers)),
model.learning_rate,
model.momentum,
model.dropout_p_input,
model.dropout_p_hidden))
# check if this configuration has already been tried
if os.path.exists(fname):
continue
# if not continue with training