当前位置: 首页>>代码示例>>Python>>正文


Python LogisticRegression.getPrediction方法代码示例

本文整理汇总了Python中LogisticRegression.LogisticRegression.getPrediction方法的典型用法代码示例。如果您正苦于以下问题:Python LogisticRegression.getPrediction方法的具体用法?Python LogisticRegression.getPrediction怎么用?Python LogisticRegression.getPrediction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LogisticRegression.LogisticRegression的用法示例。


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

示例1: evaluate_lenet5

# 需要导入模块: from LogisticRegression import LogisticRegression [as 别名]
# 或者: from LogisticRegression.LogisticRegression import getPrediction [as 别名]

#.........这里部分代码省略.........
    # the cost we minimize during training is the NLL of the model
    cost = layer3.loss_nll(y)

    # create a function to compute the mistakes that are made by the model
    train_errors = theano.function(
        inputs=[index],
        outputs=layer3.prediction_accuracy(y),
        givens={
            x: train_set_x[index * batch_size : (index + 1) * batch_size],
            y: train_set_y[index * batch_size : (index + 1) * batch_size],
        },
    )

    test_model = theano.function(
        [index],
        layer3.prediction_accuracy(y),
        givens={
            x: test_set_x[index * batch_size : (index + 1) * batch_size],
            y: test_set_y[index * batch_size : (index + 1) * batch_size],
        },
    )

    validate_model = theano.function(
        [index],
        layer3.prediction_accuracy(y),
        givens={
            x: valid_set_x[index * batch_size : (index + 1) * batch_size],
            y: valid_set_y[index * batch_size : (index + 1) * batch_size],
        },
    )

    #######################Confusion matrix code######################################
    confusion_model_train = theano.function(
        [index], layer3.getPrediction(), givens={x: train_set_x[index * batch_size : (index + 1) * batch_size]}
    )
    confusion_model_validate = theano.function(
        [index], layer3.getPrediction(), givens={x: valid_set_x[index * batch_size : (index + 1) * batch_size]}
    )
    confusion_model_test = theano.function(
        [index], layer3.getPrediction(), givens={x: test_set_x[index * batch_size : (index + 1) * batch_size]}
    )

    confusion_model_train_y = theano.function(
        [index], y, givens={y: train_set_y[index * batch_size : (index + 1) * batch_size]}
    )

    confusion_model_validate_y = theano.function(
        [index], y, givens={y: valid_set_y[index * batch_size : (index + 1) * batch_size]}
    )

    confusion_model_test_y = theano.function(
        [index], y, givens={y: test_set_y[index * batch_size : (index + 1) * batch_size]}
    )
    ###################################################################################

    # create a list of all model parameters to be fit by gradient descent
    params = layer3.params + layer2.params + layer1.params + layer0.params

    # create a list of gradients for all model parameters
    grads = T.grad(cost, params)

    # train_model is a function that updates the model parameters by
    # SGD Since this model has many parameters, it would be tedious to
    # manually create an update rule for each model parameter. We thus
    # create the updates list by automatically looping over all
    # (params[i],grads[i]) pairs.
开发者ID:sandipmukherjee,项目名称:Annuili-detection-using-Deep-learning,代码行数:70,代码来源:ConvolutionalNN.py


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