当前位置:网站首页>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.]]]
参考文献
边栏推荐
- 有孚网络受邀参加2022全国CIO大会并荣获“CIO信赖品牌”称号
- 一个免费的镜像下载仓库网站
- 单臂路由实验演示(Huawei路由器设备配置)
- Analysis of the internet jam in IM development? Network disconnection?
- Cross Site Request Forgery in PHP
- Interface automation test platform fasterrunner series (III) - operation examples
- Typescript reflection object reflection use
- 「Wdsr-3」蓬莱药局 题解
- Hough transform understanding [easy to understand]
- With a financing of 200million yuan, the former online bookstore is now closed nationwide, with only 3 stores left in 60 stores
猜你喜欢

Add a little surprise to life and be a prototype designer of creative life -- sharing with X contestants in the programming challenge

Yyds dry inventory interview must brush top101: reverse linked list

《21天精通TypeScript-4》-类型推断与语义检查

CircleIndicator组件,使指示器风格更加多样化

微软Azure和易观分析联合发布《企业级云原生平台驱动数字化转型》报告

How to design product help center? The following points cannot be ignored

上半年出货量已超去年全年,森思泰克毫米波雷达“夺食”国际巨头

Huawei switch system software upgrade and security vulnerability repair tutorial

Northeast people know sexiness best

Communication between processes (pipeline communication)
随机推荐
Esp32 S3 vscode+idf setup
浅析IM即时通讯开发出现上网卡顿?网络掉线?
基于Mysql-Exporter监控Mysql
Address book (II)
进程间的通信(管道通信)
Alibaba cloud technology expert haochendong: cloud observability - problem discovery and positioning practice
一个免费的镜像下载仓库网站
Hough transform understanding [easy to understand]
21 days proficient in typescript-4 - type inference and semantic check
7/24 training log
Korean AI team plagiarizes shock academia! One tutor with 51 students, or plagiarism recidivist
PHP 中的跨站请求伪造
ES6通过代理器(Proxy)与反射(Reflect)实现观察者模式
微软Azure和易观分析联合发布《企业级云原生平台驱动数字化转型》报告
MySQL子查询篇(精选20道子查询练习题)
The understanding of domain adaptation in transfer learning and the introduction of three technologies
The bank's wealth management subsidiary accumulates power to distribute a shares; The rectification of cash management financial products was accelerated
How to create an effective help document?
Address book (I)
房企打响“保交战”