{"id":18852590,"url":"https://github.com/quva-lab/hypersphere","last_synced_at":"2025-07-05T20:39:57.342Z","repository":{"id":69447535,"uuid":"356224344","full_name":"QUVA-Lab/HyperSphere","owner":"QUVA-Lab","description":null,"archived":false,"fork":false,"pushed_at":"2021-04-09T10:19:41.000Z","size":102,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-12-30T17:43:10.413Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/QUVA-Lab.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-09T10:04:41.000Z","updated_at":"2021-04-09T10:20:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"ce96a0e6-58e2-40a5-a37b-16d1a1ad1324","html_url":"https://github.com/QUVA-Lab/HyperSphere","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QUVA-Lab%2FHyperSphere","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QUVA-Lab%2FHyperSphere/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QUVA-Lab%2FHyperSphere/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/QUVA-Lab%2FHyperSphere/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/QUVA-Lab","download_url":"https://codeload.github.com/QUVA-Lab/HyperSphere/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239793107,"owners_count":19697892,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T03:40:40.508Z","updated_at":"2025-02-20T06:42:48.540Z","avatar_url":"https://github.com/QUVA-Lab.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HyperSphere\n\nThis is the implementation of the paper **BOCK: Bayesian Optimization with Cylindrical Kernels**(https://arxiv.org/pdf/1806.01619.pdf).\nGoal of this paper is to propose a new Bayesian Optimization algorithm for high dimensional problems. Usually, in Bayesian Optimization, we have just a handful of data compared to these days' big data. We infuse our strong prior knowledge that we want to find a solution around the center of the search space. Moreover, due to statistical efficiency, we try to keep the number of learnable optimal in a sense that it is samll enough not to degrade statistical efficiency and large enough to cover variety of functions we bump into in black-box function optimization problems.\n\n## 1. Setup\n\nTo set up this repo, go:\n\n** Virtual Environment _Without conda_ **\n\n```\ngit clone https://github.com/ChangYong-Oh/HyperSphere.git\ncd HyperSphere\nsource setup_pip.sh\n```\n\n** Virtual Environment _With conda_ **\n\n```\nconda create -n HyperSphere python=2.7.14 anaconda --yes\ncd \"`which python | xargs dirname | xargs dirname`/envs/HyperSphere\"\ngit clone https://github.com/ChangYong-Oh/HyperSphere.git\nsource HyperSphere/setup_conda.sh\n```\n\nDefault python should be the anaconda python.\n\nDifferent python version is possible. For avaialbe version search\n```\nconda search \"^python$\"\n```\n\n** Import in existing Python environment **\n\n\nOr to be able to import this code in an existing Python environment, go:\n\n```\npip install -e git+https://github.com/ChangYong-Oh/HyperSphere.git#egg=HyperSphere\n```\n\n## 2. How to run\n* Set **EXPERIMENT_DIR** in **HyperSphere/BO/run_BO.py**\n* (Default values are given) Set other configurations on acqusition function maxmization **N_SPREAD**, **N_SPRAY**, **N_INIT** in **HyperSphere/BO/acquisition/acquisition_maximization.py**\n\n\n### 2-1. Algorithm options\n* -g [sphere/cube] : 'sphere' corresponds to cylindrical transformation / 'cube' corresponds to ordinary cube search space\n* --origin [True] : This is valid only when __-g sphere__ is given, this adjusts the tranformation of the center point according to the location of the prediction point.\n* --warping [True] : This is valid only when __-g sphere__ is given, this applies learnable warping to radius component in cylindrical kernels.\n* --boundary [True] : This is valid only when __-g sphere__ is given, this adds fake point on the boundary sphere of the search space like a stationary satellite to reduce the predictive variance near the boundary.\n* --ard [True] : This is valid only when __-g cube__ is given, this makes BO use ARD kernel without cylindrical transformation.\n* --parallel [True] : Acquisition function is maximized with multiple initial points (number of initial points can be set in HyperSphere/BO/acquisition/acquisition_maximization.py). This options is for efficiency.\n\n### 2-2. Options for a function to be optimized\n* -f : The name of the python function used for evaluation\n* -e : The number of additional evaluations\n* -d : For some test functions, dimension should be specificed, otherwise, this is ignored.\n* -p : When you want to continue an experiment, you can specify the directory, this overwrites all options with the optiones specified in given directory.\n\n### 2-3. Examples\nBOCK for 95 dimensional branin with 47 evaluations (exclusive of first 2 evaluations)\n```\n../HyperSphere $ python HyperSphere/BO/run_BO.py -g sphere --origin --warping --parallel -func branin -d 95 -e 47\n```\nBOCK-W (without warping) for 32 dimensional bird with 54 evaluations (exclusive of first 2 evaluations)\n```\n../HyperSphere $ python HyperSphere/BO/run_BO.py -g sphere --origin --parallel -func bird -d 32 -e 54\n```\nBOCK+B (with boundary) for 32 dimensional bird with 54 evaluations (exclusive of first 2 evaluations)\n```\n../HyperSphere $ python HyperSphere/BO/run_BO.py -g sphere --origin --warping --boundary --parallel -func bird -d 32 -e 54\n```\nMatern for 32 dimensional bird with 54 evaluations (exclusive of first 2 evaluations)\n```\n../HyperSphere $ python HyperSphere/BO/run_BO.py -g cube --parallel -func bird -d 32 -e 54\n```\nMatern-ARD for 32 dimensional bird with 54 evaluations (exclusive of first 2 evaluations)\n```\n../HyperSphere $ python HyperSphere/BO/run_BO.py -g cube --ard --parallel -func bird -d 32 -e 54\n```\nContinuing an existing experiment with 10 more evaluations\n```\n../HyperSphere $ python HyperSphere/BO/run_BO.py -p [EXPERIMENT_DIR]/branin_D20_spherewarpingorigin_20180728-12:13:32:828257 -e 10\n```\n\n### 2-5. Optimizing new functions\nOnly thing you need to do is to provide python function for evaluation.\nWhen you have a file target.py with below function.\n```\ndef factory_cooling_bill(control_factors)\n\t...\n    return cost\nfactory_cooling_bill.dim = [number of elements in control_factors] \n#if you don't set dimension here, then dimension should be given as an option (e.g -d 57).\n```\nThen you can import this function in **HyperSphere/BO/runb_BO.py** as\n```\nfrom ../../../target import factory_cooling_bill\n```\nthen you run BO with the option **-f factory_cooling_bill**.\n\nInput for evaluation (e.g control_factors) is assumed to lie on a ball with radius D^0.5, where D is input dimension.\nPreprocessing on input can be included in the python function for evaluation.\nFor example, if you optimize layerwise learning rates for 10 layer neural network, then as a preprocessing, suggested point [x_1, ..., x_D] can be transformed into [exp(0.01 + x_1), ..., exp(0.01 + x_D)] (in this example, you are assuming that 0.01 is a good learning rate for each layer or you want to find an optima near the learning rate of 0.01).\n\nYou can refer to example files in **HyperSphere/test_functions**.\n\n### 2-6. Some implementation details\n* When selecting good initial points for acquisition function maxmization, up to 1100 dimensional problem, sobol sequence is used and for higher dimensions, uniform random is used. This may degrade the performance on the problem with dimensions \u003e 1100.\n\n\n## 3. Common Errors from sampyl\nYou may encounter some errors from sampyl package.\nThis may be due to an error in the code or bad prior specification (prior for GP hyperparameters)\n* Code errors : This occurs with old version of sampyl, sampyl appears to be updated constantly so you can check https://github.com/mcleonard/sampyl and download newest version. Or you can just replace the part of the code as below.\n* Bad prior specification : You need to set your prior so that numerical instability is prevented.\n\nBelows are the common errors I ran into.\n\n### 3-1. (code errors) ValueError: setting an array element with a sequence.\n```\nFile \"../../site-packages/sampyl/samplers/base.py\", line xxx, in sample\n    samples[i] = next(self.sampler).tovector\nValueError: setting an array element with a sequence.\n```\nYou can change the code to\n```\n    samples[i] = tuple(next(self.sampler).values())\n```\n\n### 3-2. (bad prior) Exception : Slice sampler shrank to zero!\nThis exception happens mostly when your priors for GP hyperparameters is set vulnerable to numerical instability.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquva-lab%2Fhypersphere","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquva-lab%2Fhypersphere","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquva-lab%2Fhypersphere/lists"}