• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python tf_classifier.TfMultiLayerPerceptron类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mlxtend.tf_classifier.TfMultiLayerPerceptron的典型用法代码示例。如果您正苦于以下问题:Python TfMultiLayerPerceptron类的具体用法?Python TfMultiLayerPerceptron怎么用?Python TfMultiLayerPerceptron使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TfMultiLayerPerceptron类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _clf_mlp

def _clf_mlp(trX,teX,trY,teY):
	print "MLP"
	print trX.shape,"trX shape"
	print "Enter Layer for MLP"
	layer=input()
	# print "enter delIdx"
	# delIdx=input()
	# while(delIdx):
	# 	trX=np.delete(trX,-1,axis=0)
	# 	trY=np.delete(trY,-1,axis=0)
	# 	delIdx=delIdx-1
	print "factors",factors(trX.shape[0])	
	teY=teY.astype(np.int32)
	trY=trY.astype(np.int32)
	print trX.shape,"trX shape"
	print "enter no of mini batch"
	mini_batch=int(input())
	mlp = TfMultiLayerPerceptron(eta=0.01, 
                             epochs=100, 
                             hidden_layers=layer,
                             activations=['relu' for i in range(len(layer))],
                             print_progress=3, 
                             minibatches=mini_batch, 
                             optimizer='adam',
                             random_seed=1)
	mlp.fit(trX,trY)
	pred=mlp.predict(teX)
	print _f_count(teY),"test f count"
	pred=pred.astype(np.int32)
	print _f_count(pred),"pred f count"
	conf_mat=confusion_matrix(teY, pred)
	process_cm(conf_mat, to_print=True)
	print precision_score(teY,pred),"Precision Score"
	print recall_score(teY,pred),"Recall Score"
	print roc_auc_score(teY,pred), "ROC_AUC"
开发者ID:nthakor,项目名称:imbalance_algorithms,代码行数:35,代码来源:clf_utils.py


示例2: test_fail_minibatches

def test_fail_minibatches():
    mlp = MLP(epochs=100,
              eta=0.5,
              hidden_layers=[5],
              optimizer='gradientdescent',
              activations=['logistic'],
              minibatches=13,
              random_seed=1)
    mlp.fit(X, y)
    assert (y == mlp.predict(X)).all()
开发者ID:GQiuQi,项目名称:mlxtend,代码行数:10,代码来源:tests_tf_multilayerperceptron.py


示例3: test_binary_sgd

def test_binary_sgd():
    mlp = MLP(epochs=10,
              eta=0.5,
              hidden_layers=[5],
              optimizer='gradientdescent',
              activations=['logistic'],
              minibatches=len(y_bin),
              random_seed=1)

    mlp.fit(X_bin, y_bin)
    assert (y_bin == mlp.predict(X_bin)).all()
开发者ID:GQiuQi,项目名称:mlxtend,代码行数:11,代码来源:tests_tf_multilayerperceptron.py


示例4: test_valid_acc

def test_valid_acc():
    mlp = MLP(epochs=3,
              eta=0.5,
              hidden_layers=[5],
              optimizer='gradientdescent',
              activations=['logistic'],
              minibatches=1,
              random_seed=1)

    mlp.fit(X, y, X_valid=X[:100], y_valid=y[:100])
    assert len(mlp.valid_acc_) == 3
开发者ID:GQiuQi,项目名称:mlxtend,代码行数:11,代码来源:tests_tf_multilayerperceptron.py


示例5: test_train_acc

def test_train_acc():
    mlp = MLP(epochs=3,
              eta=0.5,
              hidden_layers=[5],
              optimizer='gradientdescent',
              activations=['logistic'],
              minibatches=1,
              random_seed=1)

    mlp.fit(X, y)
    assert len(mlp.train_acc_) == 3
开发者ID:GQiuQi,项目名称:mlxtend,代码行数:11,代码来源:tests_tf_multilayerperceptron.py


示例6: test_score_function_adagrad

def test_score_function_adagrad():
    mlp = MLP(epochs=100,
              eta=0.5,
              hidden_layers=[5],
              optimizer='adagrad',
              activations=['logistic'],
              minibatches=1,
              random_seed=1)
    mlp.fit(X, y)
    acc = mlp.score(X, y)
    assert acc == 1.0, acc
开发者ID:GQiuQi,项目名称:mlxtend,代码行数:11,代码来源:tests_tf_multilayerperceptron.py


示例7: test_multiclass_gd_learningdecay

def test_multiclass_gd_learningdecay():
    mlp = MLP(epochs=5,
              eta=0.5,
              hidden_layers=[15],
              optimizer='gradientdescent',
              activations=['logistic'],
              minibatches=1,
              decay=[0.5, 1.0],
              random_seed=1)
    mlp.fit(X, y)
    expect = [3.107878, 2.124671, 1.786916, 1.65095, 1.590468]
    np.testing.assert_almost_equal(expect, mlp.cost_, decimal=2)
开发者ID:RaoUmer,项目名称:mlxtend,代码行数:12,代码来源:tests_tf_multilayerperceptron.py


示例8: test_multiclass_gd_dropout

def test_multiclass_gd_dropout():
    mlp = MLP(epochs=100,
              eta=0.5,
              hidden_layers=[5],
              optimizer='gradientdescent',
              activations=['logistic'],
              minibatches=1,
              random_seed=1,
              dropout=0.05)
    mlp.fit(X, y)
    acc = round(mlp.score(X, y), 2)
    assert acc == 0.67, acc
开发者ID:RaoUmer,项目名称:mlxtend,代码行数:12,代码来源:tests_tf_multilayerperceptron.py


示例9: test_multiclass_probas

def test_multiclass_probas():
    mlp = MLP(epochs=500,
              eta=0.5,
              hidden_layers=[10],
              optimizer='gradientdescent',
              activations=['logistic'],
              minibatches=1,
              random_seed=1)
    mlp.fit(X, y)
    idx = [0, 50, 149]  # sample labels: 0, 1, 2
    y_pred = mlp.predict_proba(X[idx])
    exp = np.array([[1.0, 0.0, 0.0],
                    [0.0, 0.9, 0.1],
                    [0.0, 0.1, 0.9]])
    np.testing.assert_almost_equal(y_pred, exp, 1)
开发者ID:GQiuQi,项目名称:mlxtend,代码行数:15,代码来源:tests_tf_multilayerperceptron.py


示例10: test_continue_learning

def test_continue_learning():
    mlp = MLP(epochs=25,
              eta=0.5,
              hidden_layers=[5],
              optimizer='gradientdescent',
              activations=['logistic'],
              minibatches=1,
              random_seed=1)
    mlp.fit(X, y)
    assert np.sum(y == mlp.predict(X)) == 144, np.sum(y == mlp.predict(X))
    mlp.fit(X, y, init_params=False)
    assert np.sum(y == mlp.predict(X)) == 150, np.sum(y == mlp.predict(X))
开发者ID:RaoUmer,项目名称:mlxtend,代码行数:12,代码来源:tests_tf_multilayerperceptron.py


示例11: test_mapping

def test_mapping():
    mlp = MLP()
    w, b = mlp._layermapping(n_features=10,
                             n_classes=11,
                             hidden_layers=[8, 7, 6])

    expect_b = {1: [[8], 'n_hidden_1'],
                2: [[7], 'n_hidden_2'],
                3: [[6], 'n_hidden_3'],
                'out': [[11], 'n_classes']}

    expect_w = {1: [[10, 8], 'n_features, n_hidden_1'],
                2: [[8, 7], 'n_hidden_1, n_hidden_2'],
                3: [[7, 6], 'n_hidden_2, n_hidden_3'],
                'out': [[6, 11], 'n_hidden_3, n_classes']}

    assert expect_b == b, b
    assert expect_w == w, w
开发者ID:GQiuQi,项目名称:mlxtend,代码行数:18,代码来源:tests_tf_multilayerperceptron.py



注:本文中的mlxtend.tf_classifier.TfMultiLayerPerceptron类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utils.assert_raises函数代码示例发布时间:2022-05-27
下一篇:
Python regressor.StackingRegressor类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap