Skip to content
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

Add an example of Goptuna suggestion service #1155

Merged
merged 1 commit into from
Apr 17, 2020

Conversation

c-bata
Copy link
Member

@c-bata c-bata commented Apr 17, 2020

What this PR does / why we need it:
Add an example of Goptuna suggestion service.

ScreenShot 2020-04-17 12 54 52

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Part of #1152

Special notes for your reviewer:

  1. This experiment is almost the same with tpe-example. I just change the name and algorithm name.
  2. Please note that Goptuna's CMA-ES does not support categorical search space. So --optimizer param is sampled by Goptuna independent sampler (default: random sampler).

Release note:

NONE

@kubeflow-bot
Copy link

This change is Reviewable

@c-bata
Copy link
Member Author

c-bata commented Apr 17, 2020

I'm in two minds which example should I add, mxnet-mnist or Himmelblau-function.

Himmelblau function

https://en.wikipedia.org/wiki/Himmelblau%27s_function

This function is quite simple and we can evaluate so fast. But it's not a realistic problem and we need to add CI setting to build docker image.

import argparse
import logging

logging.basicConfig(filename='/var/log/katib.log', level=logging.DEBUG)


def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--x1", dest='x1', type=float)
    parser.add_argument("--x2", dest='x2', type=float)

    args = parser.parse_args()
    print(args.x1, args.x2)

    evaluation = (args.x1 ** 2 + args.x2 - 11.0) ** 2 + (args.x1 + args.x2 ** 2 - 7.0) ** 2

    metric_msg = f'{{metricName: evaluation, metricValue: {evaluation:.4f}}};'
    logging.info(metric_msg)
    print(metric_msg)


if __name__ == '__main__':
    main()
FROM python:3-alpine

ADD main.py /usr/src/main.py
WORKDIR /usr/src
experiment
apiVersion: "kubeflow.org/v1alpha3"
kind: Experiment
metadata:
  namespace: kubeflow
  labels:
    controller-tools.k8s.io: "1.0"
  name: cmaes-example
spec:
  objective:
    type: minimize
    goal: 0.0001
    objectiveMetricName: evaluation
  algorithm:
    algorithmName: cmaes
  metricsCollectorSpec:
    source:
      filter:
        metricsFormat:
          - "{metricName: ([\\w|-]+), metricValue: ((-?\\d+)(\\.\\d+)?)}"
      fileSystemPath:
        path: "/var/log/katib.log"
        kind: File
    collector:
      kind: File
  parallelTrialCount: 2
  maxTrialCount: 250
  maxFailedTrialCount: 3
  parameters:
    - name: x1
      parameterType: double
      feasibleSpace:
        min: "-10"
        max: "10"
    - name: x2
      parameterType: iint
      feasibleSpace:
        min: "-10"
        max: "10"
        step: "2"
  trialTemplate:
    goTemplate:
        rawTemplate: |-
          apiVersion: batch/v1
          kind: Job
          metadata:
            name: {{.Trial}}
            namespace: {{.NameSpace}}
          spec:
            template:
              spec:
                containers:
                - name: {{.Trial}}
                  image: docker.io/cbata/hello-katib-quadratic-function
                  command:
                  - "python3"
                  - "main.py"
                  {{- with .HyperParameters}}
                  {{- range .}}
                  - "--{{.Name}} {{.Value}}"
                  {{- end}}
                  {{- end}}
                restartPolicy: Never

@c-bata c-bata mentioned this pull request Apr 17, 2020
5 tasks
@c-bata
Copy link
Member Author

c-bata commented Apr 17, 2020

/assign @andreyvelich

Copy link
Member

@gaocegege gaocegege left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm
/approve

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gaocegege

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot merged commit df78241 into kubeflow:master Apr 17, 2020
@andreyvelich
Copy link
Member

@c-bata I think, let's keep mxnet for now. If we decide that users needs another example, we can submit Himmelblau function training container.

@c-bata c-bata deleted the cmaes-example branch April 17, 2020 09:48
@c-bata
Copy link
Member Author

c-bata commented Apr 17, 2020

I see. Thanks!

sperlingxx pushed a commit to sperlingxx/katib that referenced this pull request Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants