2018 年 10 月 11 日 - 作者 Arun Subramaniyan,BHGE Digital 数据科学与分析副总裁
贝克休斯,通用电气公司 (BHGE),是全球领先的全方位油气公司,其使命是寻找更好的方法为世界提供能源。BHGE Digital 团队开发了企业级、人工智能驱动的 SaaS 解决方案,以提高效率并减少石油和天然气行业的非生产性时间。考虑任务关键型问题,例如预测燃气轮机的故障或优化大型系统(如石化工厂);这些问题需要构建和维护大规模的复杂分析。我们制定了以分析为驱动的战略,为我们的客户实现全公司范围的数字化转型。
prio_par_logC = [-23., 1.1] # [location, scale] for Normal Prior
prio_par_m = [4., 0.2] # [location, scale] for Normal Prior
rv_logC = tfd.Normal(loc=0., scale=1., name='logC_norm')
rv_m = tfd.Normal(loc=0., scale=1., name='m_norm')
为了从归一化空间采样,我们已经为两个变量定义了外部参数和标准正态分布。因此,在计算裂纹模型时,我们需要对两个随机变量进行反归一化。def joint_log_prob(cycles, observations, y0, logC_norm, m_norm):
# Joint logProbability function for both random variables and observations.
# Some constants
dsig = 75.
B = tf.constant(dsig * np.pi**0.5, tf.float32)
# Computing m and logC on original space
logC = logC_norm * prio_par_logC[1]**0.5+ prio_par_logC[0] #
m = m_norm * prio_par_m[1]**0.5 + prio_par_m[0]
# Crack Propagation model
crack_model =(cycles * tf.exp(logC) * (1 - m / 2.) * B**m + y0**(1-m / 2.))**(2. / (2. - m))
y_model = observations - crack_model
# Defining child model random variable
rv_model = tfd.Independent(
tfd.Normal(loc=tf.zeros(observations.shape), scale=0.001),
reinterpreted_batch_ndims=1, name = 'model')
# Sum of logProbabilities
return rv_logC.log_prob(logC_norm) + rv_m.log_prob(m_norm) + rv_model.log_prob(y_model)
最后,是时候设置采样器并运行 TensorFlow 会话了。# This cell can take 12 minutes to run in Graph mode
# Number of samples and burnin for the MCMC sampler
samples = 10000
burnin = 10000
# Initial state for the HMC
initial_state = [0., 0.]
# Converting the data into tensors
cycles = tf.convert_to_tensor(t_,tf.float32)
observations = tf.convert_to_tensor(y_,tf.float32)
y0 = tf.convert_to_tensor(y_[0], tf.float32)
# Setting up a target posterior for our joint logprobability
unormalized_target_posterior= lambda *args: joint_log_prob(cycles, observations, y0, *args)
# And finally setting up the mcmc sampler
[logC_samples, m_samples], kernel_results = tfp.mcmc.sample_chain(
num_results= samples,
num_burnin_steps= burnin,
current_state=initial_state,
kernel= tfp.mcmc.HamiltonianMonteCarlo(
target_log_prob_fn=unormalized_target_posterior,
step_size = 0.045,
num_leapfrog_steps=6))
# Tracking the acceptance rate for the sampled chain
acceptance_rate = tf.reduce_mean(tf.to_float(kernel_results.is_accepted))
# Actually running the sampler
# The evaluate() function, defined at the top of this notebook, runs `sess.run()`
# in graph mode and allows code to be executed eagerly when Eager mode is enabled
[logC_samples_, m_samples_, acceptance_rate_] = evaluate([
logC_samples, m_samples, acceptance_rate])
# Some initial results
print('acceptance_rate:', acceptance_rate_)
def posterior(logC_samples, m_samples, time):
n_s = len(logC_samples)
n_inputs = len(time)
# Some Constants
dsig = 75.
B = tf.constant(dsig * np.pi**0.5, tf.float32)
# Crack Propagation model - compute in the log space
y_model =(
time[:,None] *
tf.exp(logC_samples[None,:])*
(1-m_samples[None,:]/2.0) *B**m_samples[None,:] +y0** (1-m_samples[None,:]/2.0))**(2. / (2. - m_samples[None,:]))
noise = tfd.Normal(loc=0., scale=0.001)
samples = y_model + noise.sample(n_s)[tf.newaxis,:]
# The evaluate() function, defined at the top of this notebook, runs `sess.run()`
# in graph mode and allows code to be executed eagerly when Eager mode is enabled
samples_ = evaluate(samples)
return samples_
# Predict for a range of cycles
time = np.arange(0, 3000, 100)
y_samples = posterior(logC_samples_scale, m_samples_scale, time)
print(y_samples.shape)
下面显示了使用混合物理概率模型预测的裂纹长度的 95% 不确定性边界内的平均值。显然,该模型不仅捕获了平均行为,而且还估计了每个时间点的模型预测的不确定性。随着我们远离观测值,模型预测的不确定性呈指数增长。
2018 年 10 月 11 日 — 作者:Arun Subramaniyan,BHGE Digital 数据科学与分析副总裁
贝克休斯,通用电气公司 (BHGE),是全球领先的全方位油气公司,其使命是寻找更好的方法为世界提供能源。BHGE 数字团队开发企业级、AI 驱动的 SaaS 解决方案,以提高效率并减少石油和天然气行业的非生产时间。考虑 missio…