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


Python signal.html方法代碼示例

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


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

示例1: discount_cumsum

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import html [as 別名]
def discount_cumsum(x, discount):
    """Discounted cumulative sum.

    See https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#difference-equation-filtering  # noqa: E501
    Here, we have y[t] - discount*y[t+1] = x[t]
    or rev(y)[t] - discount*rev(y)[t-1] = rev(x)[t]

    Args:
        x (np.ndarrary): Input.
        discount (float): Discount factor.

    Returns:
        np.ndarrary: Discounted cumulative sum.

    """
    return scipy.signal.lfilter([1], [1, float(-discount)], x[::-1],
                                axis=0)[::-1] 
開發者ID:rlworkgroup,項目名稱:garage,代碼行數:19,代碼來源:tensor_utils.py

示例2: batch_discounted_cumsum

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import html [as 別名]
def batch_discounted_cumsum(values, discount):
    """
    Return a matrix of discounted returns.

    output[i, j] = discounted sum of returns of rewards[i, j:]

    So

    output[i, j] = rewards[i, j] + rewards[i, j+1] * discount
                    + rewards[i, j+2] * discount**2 + ...

    Based on rllab.misc.special.discounted_cumsum
    :param rewards: FloatTensor, size [batch_size, sequence_length, 1]
    :param discount: float, discount factor
    :return FloatTensor, size [batch_size, sequence_length, 1]
    """
    # See https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#difference-equation-filtering
    # Here, we have y[t] - discount*y[t+1] = x[t]
    # or reverse(y)[t] - discount*reverse(y)[t-1] = reverse(x)[t]
    return scipy.signal.lfilter(
        [1], [1, float(-discount)], values.T[::-1], axis=0,
    )[::-1].T 
開發者ID:snasiriany,項目名稱:leap,代碼行數:24,代碼來源:np_util.py

示例3: discount_cumsum

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import html [as 別名]
def discount_cumsum(x, discount):
    # See https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#difference-equation-filtering
    # Here, we have y[t] - discount*y[t+1] = x[t]
    # or rev(y)[t] - discount*rev(y)[t-1] = rev(x)[t]
    return scipy.signal.lfilter([1], [1, -discount], x[::-1], axis=0)[::-1] 
開發者ID:awslabs,項目名稱:dynamic-training-with-apache-mxnet-on-aws,代碼行數:7,代碼來源:utils.py

示例4: discount_cumsum

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import html [as 別名]
def discount_cumsum(x, discount):
    # See https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#difference-equation-filtering  # noqa: E501
    # Here, we have y[t] - discount*y[t+1] = x[t]
    # or rev(y)[t] - discount*rev(y)[t-1] = rev(x)[t]
    return scipy.signal.lfilter(
        [1], [1, float(-discount)], x[::-1], axis=0)[::-1] 
開發者ID:rlworkgroup,項目名稱:gym-sawyer,代碼行數:8,代碼來源:special.py

示例5: discount_cumsum

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import html [as 別名]
def discount_cumsum(x, gamma):
    """Compute the discounted cumulative summation of an 1-d array.
    From https://github.com/rll/rllab/blob/master/rllab/misc/special.py"""
    # See https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#difference-equation-filtering
    # Here, we have y[t] - discount*y[t+1] = x[t]
    # or rev(y)[t] - discount*rev(y)[t-1] = rev(x)[t]
    return scipy.signal.lfilter([1], [1, float(-gamma)], x[::-1], axis=0)[::-1] 
開發者ID:vacancy,項目名稱:Jacinle,代碼行數:9,代碼來源:math.py

示例6: discount_cumsum

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import html [as 別名]
def discount_cumsum(x, discount):
    """
    See https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#difference-equation-filtering

    Returns:
        (float) : y[t] - discount*y[t+1] = x[t] or rev(y)[t] - discount*rev(y)[t-1] = rev(x)[t]
    """
    return scipy.signal.lfilter([1], [1, float(-discount)], x[::-1], axis=0)[::-1] 
開發者ID:jonasrothfuss,項目名稱:ProMP,代碼行數:10,代碼來源:utils.py

示例7: discount_cumsum

# 需要導入模塊: from scipy import signal [as 別名]
# 或者: from scipy.signal import html [as 別名]
def discount_cumsum(x, discount):
    # See https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#difference-equation-filtering
    # Here, we have y[t] - discount*y[t+1] = x[t]
    # or rev(y)[t] - discount*rev(y)[t-1] = rev(x)[t]
    return scipy.signal.lfilter([1], [1, float(-discount)], x[::-1], axis=0)[::-1] 
開發者ID:PacktPublishing,項目名稱:Python-Reinforcement-Learning-Projects,代碼行數:7,代碼來源:utils.py


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