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


Python utils.shared_floatx方法代码示例

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


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

示例1: __init__

# 需要导入模块: from blocks import utils [as 别名]
# 或者: from blocks.utils import shared_floatx [as 别名]
def __init__(self, learning_rate=0.002,
                 beta1=0.1, beta2=0.001, epsilon=1e-8,
                 decay_factor=(1 - 1e-8)):
        if isinstance(learning_rate, theano.compile.SharedVariable):
            self.learning_rate = learning_rate
        else:
            self.learning_rate = shared_floatx(learning_rate, "learning_rate")
        self.beta1 = shared_floatx(beta1, "beta1")
        self.beta2 = shared_floatx(beta2, "beta2")
        self.epsilon = shared_floatx(epsilon, "epsilon")
        self.decay_factor = shared_floatx(decay_factor, "decay_factor")
        for param in [self.learning_rate, self.beta1, self.beta2, self.epsilon,
                      self.decay_factor]:
            add_role(param, ALGORITHM_HYPERPARAMETER) 
开发者ID:olimastro,项目名称:DeepMonster,代码行数:16,代码来源:optimizer.py

示例2: compute_step

# 需要导入模块: from blocks import utils [as 别名]
# 或者: from blocks.utils import shared_floatx [as 别名]
def compute_step(self, parameter, previous_step):
        mean = shared_floatx_zeros_matching(parameter, 'mean')
        add_role(mean, ALGORITHM_BUFFER)
        variance = shared_floatx_zeros_matching(parameter, 'variance')
        add_role(variance, ALGORITHM_BUFFER)
        time = shared_floatx(0., 'time')
        add_role(time, ALGORITHM_BUFFER)

        t1 = time + 1
        learning_rate = (self.learning_rate *
                         tensor.sqrt((1. - (1. - self.beta2)**t1)) /
                         (1. - (1. - self.beta1)**t1))
        beta_1t = 1 - (1 - self.beta1) * self.decay_factor ** (t1 - 1)
        mean_t = beta_1t * previous_step + (1. - beta_1t) * mean
        variance_t = (self.beta2 * tensor.sqr(previous_step) +
                      (1. - self.beta2) * variance)
        step = (learning_rate * mean_t /
                (tensor.sqrt(variance_t) + self.epsilon))

        mean.name = 'OPT_'+parameter.name + '_mean'
        variance.name = 'OPT_'+parameter.name + '_variance'
        time.name = 'OPT_'+parameter.name + '_time'

        updates = [(mean, mean_t),
                   (variance, variance_t),
                   (time, t1)]

        return step, updates 
开发者ID:olimastro,项目名称:DeepMonster,代码行数:30,代码来源:optimizer.py

示例3: __init__

# 需要导入模块: from blocks import utils [as 别名]
# 或者: from blocks.utils import shared_floatx [as 别名]
def __init__(self, initial_threshold=1.0, stdevs=4, decay=0.96,
                 clip_to_mean=True, quick_variance_convergence=True,
                 **kwargs):
        super(AdaptiveStepClipping, self).__init__(**kwargs)
        self.gnorm_log_ave = shared_floatx(numpy.log(initial_threshold),
                                           name='gnorm_log_ave')
        self.gnorm_log2_ave = shared_floatx(0, name='gnorm_log2_ave')
        self.adapt_steps = shared_floatx(0, name='adapt_steps')
        self.clip_threshold = shared_floatx(numpy.nan, name='clip_threshold')
        self.clip_level = shared_floatx(numpy.nan, name='clip_level')
        self.decay = decay
        self.stdevs = stdevs
        self.clip_to_mean = clip_to_mean
        self.quick_variance_convergence = quick_variance_convergence 
开发者ID:sotelo,项目名称:scribe,代码行数:16,代码来源:algorithms.py

示例4: __init__

# 需要导入模块: from blocks import utils [as 别名]
# 或者: from blocks.utils import shared_floatx [as 别名]
def __init__(self, eta=0, gamma=0.55, seed=180891):

        self.eta_sqrt = shared_floatx(sqrt(eta), "eta")
        add_role(self.eta_sqrt, ALGORITHM_HYPERPARAMETER)

        self.gamma_half = shared_floatx(gamma/2, "gamma")
        add_role(self.gamma_half, ALGORITHM_HYPERPARAMETER)

        self.theano_random = rng_mrg.MRG_RandomStreams(seed=seed) 
开发者ID:sohuren,项目名称:attention-sum-reader,代码行数:11,代码来源:gradient_noise.py

示例5: compute_steps

# 需要导入模块: from blocks import utils [as 别名]
# 或者: from blocks.utils import shared_floatx [as 别名]
def compute_steps(self, previous_steps):
        time = shared_floatx(0., 'time')

        t = time+1

        steps = OrderedDict(
            (parameter, self.add_noise(step, t))
            for parameter, step in previous_steps.items())

        return steps, [(time, t)] 
开发者ID:sohuren,项目名称:attention-sum-reader,代码行数:12,代码来源:gradient_noise.py


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