简体   繁体   English

约束玻尔兹曼机器中的自由能近似方程

[英]The Free energy approximation Equation in Restriction Boltzmann Machines

According a deeplearning tutorial : 根据deeplearning教程

The free energy in python is python中的自由能量是

def free_energy(self, v_sample):
    ''' Function to compute the free energy '''
    wx_b = T.dot(v_sample, self.W) + self.hbias
    vbias_term = T.dot(v_sample, self.vbias)
    hidden_term = T.sum(T.log(1 + T.exp(wx_b)), axis=1)
    return -hidden_term - vbias_term

I am not very good at python, basically it get product expert of each visible unit as vector wx_b, calculate exp and plus 1 , calculate log and sum it for the hidden term. 我不是很擅长python,基本上它将每个可见单元的产品专家作为向量wx_b,计算exp和加1,计算log并将其与隐藏项相加。

Which I believe is a little different than free energy equation in the Learning Deep Architectures: 我认为这与学习深度架构中的自由能方程略有不同:

FreeEnergy(x) = −b′x − ∑log∑e^hi(ci+Wix). FreeEnergy(x)= -b'x - ΣlogΣe^ hi(ci + Wix)。

Where: 哪里:

  • hi is the unit i hidden layer, hi是单位i隐藏层,
  • ci is the i hidden bias in vector c. cii在矢量c隐藏偏压。

It calculates exp and sum, calculate log respect to the sum value. 它计算exp和sum,计算log值对和值的影响。 after all sum all the product expert based on the number of visible unit. 毕竟根据可见单位的数量总结所有产品专家。

The above equation is eq.5.21 from Learning Deep Architectures for AI (Yoshua Bengio) 上面的等式是来自Learning Deep Architectures for AI(Yoshua Bengio)的eq.5.21

Below is my draft of java implementation vis_v is the visible layer sample, hid_v is the hidden layer unit sample. 下面是我的java实现草案,vis_v是可见层样本,hid_v是隐藏层单元样本。

private double freeEnergy(RealVector vis_v, RealVector hid_v){
 RealVector wx_hb= W.preMultiply(vis_v).add(hBias);
 double vbias_term= vis_v.dotProduct(vBias);
 double sum_hidden_term = 0;
 for(int i=0;i< wx_hb.getDimension();i++){
     RealVector vis_expert = hid_v.mapMultiply(wx_hb.getEntry(i));
     double hidden_term= StatUtils.sum(vis_expert.map(new Exp()).toArray());
     sum_hidden_term+=Math.log(hidden_term);
 }
 return -sum_hidden_term-vbias_term;
}

Is this some kind of approximation? 这是某种近似吗? I am trying to implement the same thing in java, but am getting confused over it. 我试图在java中实现相同的东西,但我对此感到困惑。 Thanks in advance for any help! 在此先感谢您的帮助!

I gather your confusion is over the definition of the free energy function in the reference python code. 我收集你的困惑是关于参考python代码中自由能函数的定义。 If this isn't what your asking I apologize. 如果这不是你的要求我道歉。

First off, this is not an approximation. 首先,这不是近似值。 It looks like they're assuming the hidden units are binary valued. 看起来他们假设隐藏单位是二进制值。 Remember, the free energy is just the (log of) the energy with hidden variables marginalized out. 请记住,自由能只是能量的(对数),隐藏的变量被边缘化了。 So, the inner sum in the free energy equation you listed above is just a sum over the values the i^th hidden unit can take on which, in this case, are {0,1}. 因此,上面列出的自由能方程中的内部和只是第i个隐藏单元可以采用的值的总和,在这种情况下,是{0,1}。 Since exp(0) = 1 that inner sum just becomes 1+exp(...). 由于exp(0)= 1,内部和恰好变为1 + exp(...)。 See the "RBMs With Binary Units" section in the link you provided . 请参阅您提供链接中的“带二进制单位的RBM”部分。

I'm not familiar with the apache commons math library in java so I can't be a huge amount of help there, but the implementation should be a straightforward translation from that python function. 我不熟悉java中的apache commons数学库所以我不能在那里提供大量的帮助,但实现应该是来自python函数的直接翻译。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM