-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
【Hackathon 6th No.31】paddle.distribution.Normal support complex normal distribution -part #65103
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
Sorry to inform you that 93adb8c's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
|
||
.. math:: | ||
|
||
Z = \pi \sigma^2 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里没有根号么
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该没有的,
若
记
python/paddle/distribution/normal.py
Outdated
if isinstance(scale, (tuple, list)): | ||
scale = np.array(scale) | ||
if scale.dtype == np.float64: | ||
scale = scale.astype('float32') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这种情况下为啥需要转换成float32呢?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里是想把 tuple 和 list 先转成 np.adarray,因为numpy的 np.array 默认是 np.float64,这里是转成paddle的默认类型。是不是这样更好一点:
if isinstance(scale, (tuple, list)):
scale = np.array(scale, dtype=np.float32)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
嗯嗯,改成这样把
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改
|
||
.. math:: | ||
|
||
entropy(\sigma) = \log (\pi e \sigma^2) + 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
辛苦确认公式的正确性,最好贴一下推导过程
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Entopy:
KL-DIV:
# used to construct another Normal object to calculate kl_divergence | ||
m2 = int((np.random.ranf() - 0.5) * 8) | ||
self.other_loc_np = m2 + m2 * 1j | ||
self.other_scale_np = int((np.random.ranf() - 0.5) * 8) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里为啥scale_np和other_scale_np后面的系数不一样
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已修改为一致
self.other_scale_np = np.random.randn(batch_size, dims).astype( | ||
'float32' | ||
) | ||
while not np.all(self.scale_np > 0): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里是不是应该是判断other_scale_np
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
应该是的,已修改
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
请更新对应的中文文档 |
PR Category
User Experience
PR Types
New features
Description
Upgarde paddle.distribution.Normal to support complex normal distribution