當前位置: 首頁>>代碼示例>>Python>>正文


Python numpy.alen方法代碼示例

本文整理匯總了Python中numpy.alen方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.alen方法的具體用法?Python numpy.alen怎麽用?Python numpy.alen使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在numpy的用法示例。


在下文中一共展示了numpy.alen方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: add_noise_to_model

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import alen [as 別名]
def add_noise_to_model(targetModel,largeNoise = False):
    #noisy_model = keras.models.clone_model(action_predictor_model)
    #noisy_model.set_weights(action_predictor_model.get_weights())
    #print("Adding Noise to actor")
    #largeNoise =  last_game_average < memoryR.mean()
    sz = len(noisy_model.layers)
    #if largeNoise:
    #    print("Setting Large Noise!")
    for k in range(sz):
        w = targetModel.layers[k].get_weights()
        if np.alen(w) >0 :
            #print("k==>",k)
            w[0] = add_noise(w[0],largeNoise)

        targetModel.layers[k].set_weights(w)
    return targetModel 
開發者ID:FitMachineLearning,項目名稱:FitML,代碼行數:18,代碼來源:ROBOTIC_Template_Experimental_v0.1.py

示例2: reset_noisy_model

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import alen [as 別名]
def reset_noisy_model():
    sz = len(noisy_model.layers)
    #if largeNoise:
    #    print("Setting Large Noise!")
    for k in range(sz):
        w = noisy_model.layers[k].get_weights()
        apW = action_predictor_model.layers[k].get_weights()

        if np.alen(w) >0:
            w[0] = reset_noisy_model_weights_to_apWeights(apW[0])
        noisy_model.layers[k].set_weights(w)
        #print("w",w)
        #print("apW",apW)


# --- Parameter Noising 
開發者ID:FitMachineLearning,項目名稱:FitML,代碼行數:18,代碼來源:ROBOTIC_Template_Experimental_v0.1.py

示例3: add_noise_to_model

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import alen [as 別名]
def add_noise_to_model(largeNoise = False):
    #noisy_model = keras.models.clone_model(action_predictor_model)
    #noisy_model.set_weights(action_predictor_model.get_weights())
    #print("Adding Noise to actor")
    #largeNoise =  last_game_average < memoryR.mean()
    sz = len(noisy_model.layers)
    #if largeNoise:
    #    print("Setting Large Noise!")
    for k in range(sz):
        w = noisy_model.layers[k].get_weights()
        #print("w ==>", w)
        if np.alen(w) >0:
            w[0] = add_noise_simple(w[0],largeNoise)

        noisy_model.layers[k].set_weights(w)
    return noisy_model

# --- Parameter Noising 
開發者ID:FitMachineLearning,項目名稱:FitML,代碼行數:20,代碼來源:Walker2D.v2.0.py

示例4: add_noise_to_model

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import alen [as 別名]
def add_noise_to_model(targetModel,largeNoise = False):
    #noisy_model = keras.models.clone_model(action_predictor_model)
    #noisy_model.set_weights(action_predictor_model.get_weights())
    #print("Adding Noise to actor")
    #largeNoise =  last_game_average < memoryR.mean()
    sz = len(noisy_model.layers)
    #if largeNoise:
    #    print("Setting Large Noise!")
    for k in range(sz):
        w = targetModel.layers[k].get_weights()
        if np.alen(w) >0 :
            #print("k==>",k)
            if USE_GAUSSIAN_NOISE:
                w[0] = add_gaussian_noise(w[0],big_sigma,largeNoise)
            else:
                w[0] = add_noise_simple(w[0],largeNoise)

        targetModel.layers[k].set_weights(w)
    return targetModel 
開發者ID:FitMachineLearning,項目名稱:FitML,代碼行數:21,代碼來源:AntBulletEnv.py

示例5: alen

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import alen [as 別名]
def alen(a):
    """
    Return the length of the first dimension of the input array.

    Parameters
    ----------
    a : array_like
       Input array.

    Returns
    -------
    alen : int
       Length of the first dimension of `a`.

    See Also
    --------
    shape, size

    Examples
    --------
    >>> a = np.zeros((7,4,5))
    >>> a.shape[0]
    7
    >>> np.alen(a)
    7

    """
    try:
        return len(a)
    except TypeError:
        return len(array(a, ndmin=1)) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:33,代碼來源:fromnumeric.py

示例6: ramp_2D

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import alen [as 別名]
def ramp_2D(geometry):
    detector_width = geometry.detector_shape[np.alen(geometry.detector_shape) - 1]

    filter = [
        np.reshape(
            ramp(detector_width),
            (1, detector_width)
        )
        for i in range(0, geometry.number_of_projections)
    ]

    filter = np.concatenate(filter)

    return filter 
開發者ID:csyben,項目名稱:PYRO-NN,代碼行數:16,代碼來源:filters.py

示例7: ramp_3D

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import alen [as 別名]
def ramp_3D(geometry):
    detector_width = geometry.detector_shape[np.alen(geometry.detector_shape) - 1]

    filter = [
        np.reshape(
            ramp(detector_width),
            (1, 1, detector_width)
        )
        for i in range(0, geometry.number_of_projections)
    ]

    filter = np.concatenate(filter)

    return filter 
開發者ID:csyben,項目名稱:PYRO-NN,代碼行數:16,代碼來源:filters.py

示例8: ram_lak_2D

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import alen [as 別名]
def ram_lak_2D(geometry):
    detector_width = geometry.detector_shape[np.alen(geometry.detector_shape) - 1]
    detector_spacing_width = geometry.detector_spacing[np.alen(geometry.detector_spacing) - 1]

    filter = [
        np.reshape(
            ram_lak(detector_width, detector_spacing_width),
            (1, detector_width)
        )
        for i in range(0, geometry.number_of_projections)
    ]

    filter = np.concatenate(filter)

    return filter 
開發者ID:csyben,項目名稱:PYRO-NN,代碼行數:17,代碼來源:filters.py

示例9: ram_lak_3D

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import alen [as 別名]
def ram_lak_3D(geometry):
    detector_width = geometry.detector_shape[np.alen(geometry.detector_shape) - 1]
    detector_spacing_width = geometry.detector_spacing[np.alen(geometry.detector_spacing) - 1]

    filter = [
        np.reshape(
            ram_lak(detector_width, detector_spacing_width),
            (1, 1, detector_width)
        )
        for i in range(0, geometry.number_of_projections)
    ]

    filter = np.concatenate(filter)

    return (1 / 1.0) * filter 
開發者ID:csyben,項目名稱:PYRO-NN,代碼行數:17,代碼來源:filters.py

示例10: scale_weights

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import alen [as 別名]
def scale_weights(memR,memW):
    rmax = memR.max()
    rmin = memR.min()
    reward_range = math.fabs(rmax - rmin )
    if reward_range == 0:
        reward_range = 10
    for i in range(np.alen(memR)):
        memW[i][0] = math.fabs(memR[i][0]-rmin)/reward_range
        memW[i][0] = max(memW[i][0],0.001)
        #print("memW %5.2f reward %5.2f rmax %5.2f rmin %5.2f "%(memW[i][0],memR[i][0],rmax,rmin))
    #print("memW",memW)
    return memW 
開發者ID:FitMachineLearning,項目名稱:FitML,代碼行數:14,代碼來源:ROBOTIC_Template_Experimental_v0.1.py

示例11: pr_actor_experience_replay

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import alen [as 別名]
def pr_actor_experience_replay(memSA,memR,memS,memA,memW,num_epochs=1):
    tSA = (memSA)
    tR = (memR)
    tX = (memS)
    tY = (memA)
    tW = (memW)


    tX_train = np.zeros(shape=(1,num_env_variables))
    tY_train = np.zeros(shape=(1,num_env_actions))
    for i in range(np.alen(tR)):
        pr = predictTotalRewards(tX[i],GetRememberedOptimalPolicy(tX[i]))
        #print ("tR[i]",tR[i],"pr",pr)
        d = math.fabs( memoryR.max() - pr)
        tW[i]= 0.0000000000000005
        if (tR[i]>pr):
            tW[i]=0.15
        if (tR[i]>pr+d/2):
            tW[i] = 1
        if tW[i]> np.random.rand(1):
            tX_train = np.vstack((tX_train,tX[i]))
            tY_train = np.vstack((tY_train,tY[i]))


    tX_train = tX_train[1:]
    tY_train = tY_train[1:]
    print("%8d were better After removing first element"%np.alen(tX_train))
    if np.alen(tX_train)>0:
        action_predictor_model.fit(tX_train,tY_train, batch_size=mini_batch, nb_epoch=num_epochs,verbose=0) 
開發者ID:FitMachineLearning,項目名稱:FitML,代碼行數:31,代碼來源:ROBOTIC_Template_Experimental_v0.1.py

示例12: train_noisy_actor

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import alen [as 別名]
def train_noisy_actor():
    tX = (memoryS)
    tY = (memoryA)
    tW = (memoryW)

    train_A = np.random.randint(tY.shape[0],size=int(min(experience_replay_size,np.alen(tY) )))
    tX = tX[train_A,:]
    tY = tY[train_A,:]
    tW = tW[train_A,:]

    noisy_model.fit(tX,tY, batch_size=mini_batch, nb_epoch=training_epochs,verbose=0) 
開發者ID:FitMachineLearning,項目名稱:FitML,代碼行數:13,代碼來源:ROBOTIC_Template_Experimental_v0.1.py


注:本文中的numpy.alen方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。