|
|
|
@@ -10,7 +10,19 @@ import { useComputingResource } from '@/hooks/resource'; |
|
|
|
import { isEmpty } from '@/utils'; |
|
|
|
import { modalConfirm } from '@/utils/ui'; |
|
|
|
import { MinusCircleOutlined, PlusCircleOutlined, QuestionCircleOutlined } from '@ant-design/icons'; |
|
|
|
import { Button, Col, Flex, Form, Input, InputNumber, Radio, Row, Select, Tooltip } from 'antd'; |
|
|
|
import { |
|
|
|
Button, |
|
|
|
Col, |
|
|
|
Flex, |
|
|
|
Form, |
|
|
|
Input, |
|
|
|
InputNumber, |
|
|
|
Radio, |
|
|
|
Row, |
|
|
|
Select, |
|
|
|
Tooltip, |
|
|
|
Typography, |
|
|
|
} from 'antd'; |
|
|
|
import { isEqual } from 'lodash'; |
|
|
|
import PopParameterRange from './PopParameterRange'; |
|
|
|
import styles from './index.less'; |
|
|
|
@@ -22,47 +34,58 @@ import { |
|
|
|
type FormParameter, |
|
|
|
} from './utils'; |
|
|
|
|
|
|
|
const parameterTooltip = `uniform(-5, -1) |
|
|
|
在 -5.0 和 -1.0 之间均匀采样浮点数 |
|
|
|
|
|
|
|
quniform(3.2, 5.4, 0.2) |
|
|
|
在 3.2 和 5.4 之间均匀采样浮点数,四舍五入到 0.2 的倍数 |
|
|
|
const parameterTooltip = `uniform(low, high) |
|
|
|
在 low 和 high 之间均匀采样浮点数 |
|
|
|
|
|
|
|
quniform(low, high, q) |
|
|
|
在 low 和 high 之间均匀采样浮点数,四舍五入到 q 的倍数 |
|
|
|
|
|
|
|
loguniform(1e-4, 1e-2) |
|
|
|
在 0.0001 和 0.01 之间均匀采样浮点数,对数空间采样 |
|
|
|
loguniform(low, high) |
|
|
|
在 low 和 high 之间均匀采样浮点数,对数空间采样 |
|
|
|
|
|
|
|
qloguniform(1e-4, 1e-1, 5e-5) |
|
|
|
在 0.0001 和 0.01 之间均匀采样浮点数,对数空间采样并四舍五入到 0.00005 的倍数 |
|
|
|
qloguniform(low, high, q) |
|
|
|
在 low 和 high 之间均匀采样浮点数,对数空间采样并四舍五入到 q 的倍数 |
|
|
|
|
|
|
|
randn(10, 2) |
|
|
|
在均值为 10,方差为 2 的正态分布中进行随机浮点数抽样 |
|
|
|
randn(m, s) |
|
|
|
在均值为 m,方差为 s 的正态分布中进行随机浮点数抽样 |
|
|
|
|
|
|
|
qrandn(10, 2, 0.2) |
|
|
|
在均值为 10,方差为 2 的正态分布中进行随机浮点数抽样,四舍五入到 0.2 的倍数 |
|
|
|
qrandn(m, s, q) |
|
|
|
在均值为 m,方差为 s 的正态分布中进行随机浮点数抽样,四舍五入到 q 的倍数 |
|
|
|
|
|
|
|
randint(-9, 15) |
|
|
|
在 -9(包括)到 15(不包括)之间均匀采样整数 |
|
|
|
randint(low, high) |
|
|
|
在 low(包括)到 high(不包括)之间均匀采样整数 |
|
|
|
|
|
|
|
qrandint(-21, 12, 3) |
|
|
|
在 -21(包括)到 12(不包括)之间均匀采样整数,四舍五入到 3 的倍数 |
|
|
|
qrandint(low, high, q) |
|
|
|
在 low(包括)到 high(不包括)之间均匀采样整数,四舍五入到 q 的倍数(包括 high) |
|
|
|
|
|
|
|
lograndint(1, 10) |
|
|
|
在 1(包括)到 10(不包括)之间均匀采样整数,对数空间采样 |
|
|
|
lograndint(low, high) |
|
|
|
在 low(包括)到 high(不包括)之间对数空间上均匀采样整数 |
|
|
|
|
|
|
|
qlograndint(1, 10, 2) |
|
|
|
在 1(包括)到 10(不包括)之间均匀采样整数,对数空间采样并四舍五入到 2 的倍数 |
|
|
|
qlograndint(low, high, q) |
|
|
|
在 low(包括)到 high(不包括)之间对数空间上均匀采样整数,并四舍五入到 q 的倍数 |
|
|
|
|
|
|
|
choice(["a", "b", "c"]) |
|
|
|
choice |
|
|
|
从指定的选项中采样一个选项 |
|
|
|
|
|
|
|
grid([32, 64, 128]) |
|
|
|
对这些值进行网格搜索,每个值都将被采样 |
|
|
|
grid |
|
|
|
对选项进行网格搜索,每个值都将被采样 |
|
|
|
`; |
|
|
|
|
|
|
|
const axParameterTooltip = `fixed |
|
|
|
固定取值 |
|
|
|
|
|
|
|
range(low, high) |
|
|
|
在 low 和 high 范围内采样取值 |
|
|
|
|
|
|
|
choice |
|
|
|
从指定的选项中采样一个选项 |
|
|
|
`; |
|
|
|
|
|
|
|
function ExecuteConfig() { |
|
|
|
const form = Form.useFormInstance(); |
|
|
|
const searchAlgorithm = Form.useWatch('search_alg', form); |
|
|
|
const paramsTypeOptions = searchAlgorithm === 'Ax' ? axParameterOptions : parameterOptions; |
|
|
|
const paramsTypeTooltip = searchAlgorithm === 'Ax' ? axParameterTooltip : parameterTooltip; |
|
|
|
const [resourceStandardList, filterResourceStandard] = useComputingResource(); |
|
|
|
|
|
|
|
const handleSearchAlgorithmChange = (value: string) => { |
|
|
|
@@ -117,6 +140,29 @@ function ExecuteConfig() { |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
|
|
|
|
<Row gutter={8}> |
|
|
|
<Col span={10}> |
|
|
|
<Form.Item |
|
|
|
label="镜像" |
|
|
|
name="image" |
|
|
|
rules={[ |
|
|
|
{ |
|
|
|
validator: requiredValidator, |
|
|
|
message: '请选择镜像', |
|
|
|
}, |
|
|
|
]} |
|
|
|
required |
|
|
|
> |
|
|
|
<ResourceSelect |
|
|
|
type={ResourceSelectorType.Mirror} |
|
|
|
placeholder="请选择镜像" |
|
|
|
canInput={false} |
|
|
|
size="large" |
|
|
|
/> |
|
|
|
</Form.Item> |
|
|
|
</Col> |
|
|
|
</Row> |
|
|
|
|
|
|
|
<Row gutter={8}> |
|
|
|
<Col span={10}> |
|
|
|
<Form.Item |
|
|
|
@@ -263,7 +309,7 @@ function ExecuteConfig() { |
|
|
|
<div className={styles['hyper-parameter__header__type']}> |
|
|
|
参数类型 |
|
|
|
<Tooltip |
|
|
|
title={parameterTooltip} |
|
|
|
title={paramsTypeTooltip} |
|
|
|
placement="top" |
|
|
|
arrow={{ pointAtCenter: true }} |
|
|
|
overlayClassName={styles['hyper-parameter__header__tooltip']} |
|
|
|
@@ -402,9 +448,13 @@ function ExecuteConfig() { |
|
|
|
rules={[ |
|
|
|
{ |
|
|
|
validator: (_, runParameters) => { |
|
|
|
const parameters = form.getFieldValue('parameters'); |
|
|
|
const parameters = form |
|
|
|
.getFieldValue('parameters') |
|
|
|
.filter( |
|
|
|
(item: FormParameter | undefined) => item !== undefined && item !== null, |
|
|
|
); |
|
|
|
for (const item of parameters) { |
|
|
|
const name = item.name; |
|
|
|
const name = item?.name; |
|
|
|
const arr = runParameters.filter((item?: Record<string, any>) => |
|
|
|
isEmpty(item?.[name]), |
|
|
|
); |
|
|
|
@@ -437,7 +487,11 @@ function ExecuteConfig() { |
|
|
|
{parameters.map((item: FormParameter) => ( |
|
|
|
<Form.Item |
|
|
|
key={item.name} |
|
|
|
label={item.name} |
|
|
|
label={ |
|
|
|
<Typography.Text ellipsis={{ tooltip: item.name }}> |
|
|
|
{item.name} |
|
|
|
</Typography.Text> |
|
|
|
} |
|
|
|
{...restField} |
|
|
|
labelCol={{ flex: '140px' }} |
|
|
|
name={[name, item.name]} |
|
|
|
|