当前位置:网站首页>Pymoo学习 (8):Gradients
Pymoo学习 (8):Gradients
2022-07-25 18:59:00 【因吉】
文章目录
1 Gradients
如果优化问题使用autograd实现,那么可以通过AutomaticDifferentiation来处理:
import autograd.numpy as anp
from pymoo.core.problem import Problem
from pymoo.problems.autodiff import AutomaticDifferentiation
class MyProblem(Problem):
def __init__(self):
super().__init__(n_var=10, n_obj=1, n_constr=0, xl=-5, xu=5)
def _evaluate(self, x, out, *args, **kwargs):
out["F"] = anp.sum(anp.power(x, 2), axis=1)
if __name__ == '__main__':
problem = AutomaticDifferentiation(MyProblem())
X = anp.array([anp.arange(10)])
F, dF = problem.evaluate(X, return_values_of=["F", "dF"])
print(X, F)
print(dF.shape)
print(dF)
输出如下:
[[0 1 2 3 4 5 6 7 8 9]] [[285.]]
(1, 1, 10)
[[[ 0. 2. 4. 6. 8. 10. 12. 14. 16. 18.]]]
参考文献
边栏推荐
- 接口自动化测试平台FasterRunner系列(二)- 功能模块
- 《21天精通TypeScript-4》-类型推断与语义检查
- Process communication (Systemv communication mode: shared memory, message queue, semaphore)
- ThreadLocal Kills 11 consecutive questions
- [open source project] stm32c8t6 + ADC signal acquisition + OLED waveform display
- 关爱一线防疫工作者,浩城嘉业携手高米店街道办事处共筑公益长城
- Interface automation test platform fasterrunner series (II) - function module
- SQL realizes 10 common functions of Excel, with original interview questions attached
- Go code checking tool
- 浅析IM即时通讯开发出现上网卡顿?网络掉线?
猜你喜欢

人人可参与开源活动正式上线,诚邀您来体验!

21 days proficient in typescript-4 - type inference and semantic check

Share six practical applet plug-ins

What is hpapaas platform?

Communication between processes (pipeline communication)

优秀的测试/开发程序员突破,不忘初心,方得始终......

华为年内二度招聘“天才少年”;540万Twitter账号信息泄露,卖价3万美元;谷歌解雇了相信AI有意识的工程师|极客头条

8 年产品经验,我总结了这些持续高效研发实践经验 · 研发篇

【Web技术】1391- 页面可视化搭建工具前生今世

【919. 完全二叉树插入器】
随机推荐
Typescript object proxy use
单臂路由实验演示(Huawei路由器设备配置)
Communication between processes (pipeline communication)
SQL realizes 10 common functions of Excel, with original interview questions attached
如何创建一个有效的帮助文档?
Qtimgui compilation
阿里云技术专家秦隆:可靠性保障必备——云上如何进行混沌工程?
A free image download warehouse website
Alibaba cloud technology expert Qin long: reliability assurance is a must - how to carry out chaos engineering on the cloud?
F5: Six capabilities required for enterprise digital transformation
弱网测试工具-QNET
What is national debt reverse repurchase? Is it safe?
Ultimate doll 2.0 | cloud native delivery package
What is hpapaas platform?
Yarn installation and use tutorial [easy to understand]
歌曲转调之后和弦如何转换
[encryption weekly] has the encryption market recovered? The cold winter has not thawed yet! Check the major events in the encryption market last week!
虚拟机vmware安装步骤(如何在虚拟机安装软件)
Interface automation test platform fasterrunner series (II) - function module
MySQL子查询篇(精选20道子查询练习题)