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


Python ELM.train方法代码示例

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


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

示例1: test_TrainWithBatch_OverwritesBatch

# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import train [as 别名]
 def test_TrainWithBatch_OverwritesBatch(self):
     elm = ELM(1, 1, batch=123)
     X = np.array([1, 2, 3])
     T = np.array([1, 2, 3])
     elm.add_neurons(1, "lin")
     elm.train(X, T, batch=234)
     self.assertEqual(234, elm.batch)
开发者ID:IstanbulBoy,项目名称:hpelm,代码行数:9,代码来源:test_correctness.py

示例2: test_MultiLabelClassification_Works

# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import train [as 别名]
 def test_MultiLabelClassification_Works(self):
     elm = ELM(1, 2)
     X = np.array([1, 2, 3, 4, 5, 6])
     T = np.array([[1, 1], [1, 0], [1, 0], [0, 1], [0, 1], [1, 1]])
     elm.add_neurons(1, "lin")
     elm.train(X, T, 'ml')
     elm.train(X, T, 'mc')
开发者ID:IstanbulBoy,项目名称:hpelm,代码行数:9,代码来源:test_correctness.py

示例3: test_ELM_SaveLoad

# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import train [as 别名]
 def test_ELM_SaveLoad(self):
     X = np.array([1, 2, 3, 1, 2, 3])
     T = np.array([[1, 0], [1, 0], [1, 0], [0, 1], [0, 1], [0, 1]])
     elm = ELM(1, 2, precision='32', norm=0.02)
     elm.add_neurons(1, "lin")
     elm.add_neurons(2, "tanh")
     elm.train(X, T, "wc", w=(0.7, 0.3))
     B1 = elm.nnet.get_B()
     try:
         f, fname = tempfile.mkstemp()
         elm.save(fname)
         elm2 = ELM(3, 3)
         elm2.load(fname)
     finally:
         os.close(f)
     self.assertEqual(elm2.nnet.inputs, 1)
     self.assertEqual(elm2.nnet.outputs, 2)
     self.assertEqual(elm2.classification, "wc")
     self.assertIs(elm.precision, np.float32)
     self.assertIs(elm2.precision, np.float64)  # precision has changed
     np.testing.assert_allclose(np.array([0.7, 0.3]), elm2.wc)
     np.testing.assert_allclose(0.02, elm2.nnet.norm)
     np.testing.assert_allclose(B1, elm2.nnet.get_B())
     self.assertEqual(elm2.nnet.get_neurons()[0][1], "lin")
     self.assertEqual(elm2.nnet.get_neurons()[1][1], "tanh")
开发者ID:IstanbulBoy,项目名称:hpelm,代码行数:27,代码来源:test_correctness.py

示例4: HPELMNN

# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import train [as 别名]
class HPELMNN(Classifier):
    
    def __init__(self):
        self.__hpelm = None
    
    @staticmethod
    def name():
        return "hpelmnn"

    def train(self, X, Y, class_number=-1):
        class_count = max(np.unique(Y).size, class_number)
        feature_count = X.shape[1]
        self.__hpelm = ELM(feature_count, class_count, 'wc')
        self.__hpelm.add_neurons(feature_count, "sigm")

        Y_arr = Y.reshape(-1, 1)
        enc = OneHotEncoder()
        enc.fit(Y_arr)
        Y_OHE = enc.transform(Y_arr).toarray()

        out_fd = sys.stdout
        sys.stdout = open(os.devnull, 'w')
        self.__hpelm.train(X, Y_OHE)
        sys.stdout = out_fd

    def predict(self, X):
        Y_predicted = self.__hpelm.predict(X)
        return Y_predicted
开发者ID:grzesiekzajac,项目名称:ziwm,代码行数:30,代码来源:hpelmnn.py

示例5: test_Classification_WorksCorreclty

# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import train [as 别名]
 def test_Classification_WorksCorreclty(self):
     elm = ELM(1, 2)
     X = np.array([-1, -0.6, -0.3, 0.3, 0.6, 1])
     T = np.array([[1, 0], [1, 0], [1, 0], [0, 1], [0, 1], [0, 1]])
     elm.add_neurons(1, "lin")
     elm.train(X, T, 'c')
     Y = elm.predict(X)
     self.assertGreater(Y[0, 0], Y[0, 1])
     self.assertLess(Y[5, 0], Y[5, 1])
开发者ID:IstanbulBoy,项目名称:hpelm,代码行数:11,代码来源:test_correctness.py

示例6: test_WeightedClassification_ClassWithLargerWeightWins

# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import train [as 别名]
 def test_WeightedClassification_ClassWithLargerWeightWins(self):
     elm = ELM(1, 2)
     X = np.array([1, 2, 3, 1, 2, 3])
     T = np.array([[1, 0], [1, 0], [1, 0], [0, 1], [0, 1], [0, 1]])
     elm.add_neurons(1, "lin")
     elm.train(X, T, 'wc', w=(1, 0.1))
     Y = elm.predict(X)
     self.assertGreater(Y[0, 0], Y[0, 1])
     self.assertGreater(Y[1, 0], Y[1, 1])
     self.assertGreater(Y[2, 0], Y[2, 1])
开发者ID:IstanbulBoy,项目名称:hpelm,代码行数:12,代码来源:test_correctness.py

示例7: build_ELM_encoder

# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import train [as 别名]
def build_ELM_encoder(xinput, target, num_neurons):


    elm = ELM(xinput.shape[1], target.shape[1])
    elm.add_neurons(num_neurons, "sigm")
    elm.add_neurons(num_neurons, "lin")
    #elm.add_neurons(num_neurons, "rbf_l1")
    elm.train(xinput, target, "r")
    ypred = elm.predict(xinput)
    print "mse error", elm.error(ypred, target)
    return elm, ypred
开发者ID:btekgit,项目名称:mitosisdetection,代码行数:13,代码来源:elmTest.py

示例8: test_LOOandOP_CanSelectMoreThanOneNeuron

# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import train [as 别名]
 def test_LOOandOP_CanSelectMoreThanOneNeuron(self):
     X = np.random.rand(100, 5)
     T = np.random.rand(100, 2)
     for _ in range(10):
         model = ELM(5, 2)
         model.add_neurons(5, 'lin')
         model.train(X, T, 'LOO', 'OP')
         max2 = model.nnet.L
         if max2 > 1:
             break
     self.assertGreater(max2, 1)
开发者ID:akusok,项目名称:hpelm,代码行数:13,代码来源:unittest_elm.py

示例9: test_CrossValidation_ReturnsError

# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import train [as 别名]
 def test_CrossValidation_ReturnsError(self):
     model = ELM(5, 2)
     model.add_neurons(10, 'tanh')
     X = np.random.rand(100, 5)
     T = np.random.rand(100, 2)
     err = model.train(X, T, 'CV', k=3)
     self.assertIsNotNone(err)
开发者ID:akusok,项目名称:hpelm,代码行数:9,代码来源:unittest_elm.py

示例10: test_MRSR2_Works

# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import train [as 别名]
 def test_MRSR2_Works(self):
     X = np.random.rand(20, 9)
     T = np.random.rand(20, 12)
     elm = ELM(9, 12)
     elm.add_neurons(5, "tanh")
     elm.train(X, T, "LOO", "OP")
开发者ID:IstanbulBoy,项目名称:hpelm,代码行数:8,代码来源:test_correctness.py

示例11: test_WeightedClassification_DefaultWeightsWork

# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import train [as 别名]
 def test_WeightedClassification_DefaultWeightsWork(self):
     elm = ELM(1, 2)
     X = np.array([1, 2, 3, 1, 2, 3])
     T = np.array([[1, 0], [1, 0], [1, 0], [0, 1], [0, 1], [0, 1]])
     elm.add_neurons(1, "lin")
     elm.train(X, T, 'wc')
开发者ID:IstanbulBoy,项目名称:hpelm,代码行数:8,代码来源:test_correctness.py

示例12: calc_W_B_para

# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import train [as 别名]
def calc_W_B_para(C=0.7,input_node_num=input_node_num,hide_node_num=hide_node_num,):
    beta=C*math.pow(hide_node_num,(1/float(input_node_num)))
    W_old=np.random.uniform(-0.5,0.5,size=(input_node_num,hide_node_num))

    if input_node_num == 1:
        W_old = W_old / np.abs(W_old)
    else:
        W_old = np.sqrt(1. / np.square(W_old).sum(axis=1).reshape(input_node_num, 1)) * W_old
    W_new=beta*W_old
    Bias=np.random.uniform(-beta,beta,size=(hide_node_num,))
    return [W_new,Bias]
W,B=calc_W_B_para()

elm = ELM(input_node_num,output_node_num,ak=ak,bk=bk)
elm.add_neurons(20, "avg_arcsinh_morlet",W=W,B=B)
elm.train(X_learn, Y_learn, "r")

def plot_prognostic(train_out):

    inputs_regressors_num=list(X_learn[len(X_learn)-1,:])

    len_just_prog=len_prognostics-1100
    FC1_prognostics=[]
    for i in range(len_just_prog):
        if i <regressors_num:
            if i ==0:
                inputs=list(inputs_regressors_num)
                inputs=np.array(inputs)
                inputs.resize(1,4)
                FC1_prognostics.append(elm.predict(inputs))
            elif i>=1:
开发者ID:Newsteinwell,项目名称:write-code,代码行数:33,代码来源:elm_test.py

示例13: test_8_OneDimensionTargets_RunsCorrectly

# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import train [as 别名]
 def test_8_OneDimensionTargets_RunsCorrectly(self):
     X = np.array([[1, 2], [3, 4], [5, 6]])
     T = np.array([[0], [0], [0]])
     elm = ELM(2, 1)
     elm.add_neurons(1, "lin")
     elm.train(X, T)
开发者ID:ExtremeLearningMachines,项目名称:hpelm0.6.6,代码行数:8,代码来源:test_correctness.py

示例14: test_7_ZeroInputs_RunsCorrectly

# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import train [as 别名]
 def test_7_ZeroInputs_RunsCorrectly(self):
     X = np.array([[0, 0], [0, 0], [0, 0]])
     T = np.array([1, 2, 3])
     elm = ELM(2, 1)
     elm.add_neurons(1, "lin")
     elm.train(X, T)
开发者ID:ExtremeLearningMachines,项目名称:hpelm0.6.6,代码行数:8,代码来源:test_correctness.py

示例15: test_4_OneDimensionTargets_RunsCorrectly

# 需要导入模块: from hpelm import ELM [as 别名]
# 或者: from hpelm.ELM import train [as 别名]
 def test_4_OneDimensionTargets_RunsCorrectly(self):
     X = np.array([1, 2, 3])
     T = np.array([1, 2, 3])
     elm = ELM(1, 1)
     elm.add_neurons(1, "lin")
     elm.train(X, T)
开发者ID:ExtremeLearningMachines,项目名称:hpelm0.6.6,代码行数:8,代码来源:test_correctness.py


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