快速SVM实现与神经网络深度学习
1. 快速SVM实现
1.1 VW中的神经网络
VW能够实现带有双曲正切(tanh)激活函数的单层神经网络,还可选择使用dropout(通过 --dropout 选项)。虽然只能决定神经元的数量,但这种神经网络在回归和分类问题上都表现出色,并且可以平滑地接受VW的其他转换作为输入,如二次变量和n - 元组。以下是将其应用于波士顿数据集的示例代码:
params = 'boston.vw -f boston.model --loss_function squared -k --cache_file cache_train.vw --passes=20 --nn 5 --dropout'
results = execute_vw(params)
params = '-t boston.vw -i boston.model -k --cache_file cache_test.vw -p boston.test'
results = execute_vw(params)
val_rmse = 0
with open('boston.test', 'rb') as R:
with open('boston.vw', 'rb') as TRAIN:
holdouts = 0.0
for n,(line, example) in enumerate(zip(R,TRAIN)):
if (n+1) % 10==0:
predicted = float(line.strip
超级会员免费看
订阅专栏 解锁全文
36万+

被折叠的 条评论
为什么被折叠?



