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


Python NeuralNetwork.setAlpha方法代码示例

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


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

示例1: __init__

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

#.........这里部分代码省略.........
                self.file.write("Training iteration so far: " + str(totalIter) + "\n")
                self.test(training_data, "training")
                self.test(testData, "testing")
                iteration -= testSize

            if iteration > 0:
                self.clf.train(iteration, batchSize)
                totalIter += iteration
                print "---------- Settings ----------"
                print "Examples                 :", training_data.shape[0]
                print "Batch size               :", batchSize
                print "Alpha                    :", self.clf.getAlpha()
                print "Momentum factor          :", momentumFactor
                print "# of Nodes in all layers :", nodeNum
                print "Training iteration so far:", totalIter
                self.file.write("\n")
                self.file.write("---------- Settings ----------" + "\n")
                self.file.write("Examples                 : " + str(training_data.shape[0]) + "\n")
                self.file.write("Batch size               : " + str(batchSize) + "\n")
                self.file.write("Alpha                    : " + str(self.clf.getAlpha()) + "\n")
                self.file.write("Momentum factor          : " + str(momentumFactor) + "\n")
                self.file.write("# of Nodes in all layers : " + str(nodeNum) + "\n")
                self.file.write("Training iteration so far: " + str(totalIter) + "\n")
                self.test(training_data, "training")
                self.test(testData, "testing")
                iteration = 0

            print ""
            restart = raw_input("Do you want to restart? (Y/N)")
            if restart.upper() == "Y":
                totalIter = 0
                print "Current Alpha is", self.clf.getAlpha()
                alpha = raw_input("What alpha ?")
                self.clf.setAlpha(float(alpha))
                self.clf.initTheta()
                self.file.write("\n")
                self.file.write("*****************************************************\n")
                self.file.write("Re-initialize trail with alpha = " + str(alpha) + "\n")
                self.file.write("*****************************************************\n")

            print ""
            iteration = raw_input("How many iteration do you want to train the model?")
            try:
                iteration = int(iteration)
            except:
                iteration = raw_input("Please input an integer")
                iteration = 1
        print "Total training iterations:", totalIter

    def predict(self, data):
        """

        """
        return self.clf.predict(data)

    def test(self, test_data, mode):
        """

        """
        correct = 0
        countPrediction = {}
        countCorrect = {}
        countTotal = Counter(list(test_data[:, 0]))
        allPrediction = {}

        labels = np.unique(test_data[:, 0])
开发者ID:jasonlingo,项目名称:Machine-Learning-Assignments,代码行数:70,代码来源:classifier.py


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