การค้นหาแบบสุ่ม
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
หน่วยนี้มุ่งเน้นที่การค้นหาแบบเกือบสุ่ม
เหตุผลที่ควรใช้การค้นหาแบบเกือบสุ่ม
เราเลือกใช้การค้นหาแบบเกือบสุ่ม (ตามลําดับความคลาดเคลื่อนต่ำ) มากกว่าเครื่องมือเพิ่มประสิทธิภาพแบบกล่องดำที่ดูล้ำสมัยกว่า เมื่อใช้เป็นส่วนหนึ่งของกระบวนการปรับแต่งแบบวนซ้ำโดยมีจุดประสงค์เพื่อเพิ่มข้อมูลเชิงลึกเกี่ยวกับปัญหาการปรับแต่งให้ได้สูงสุด (สิ่งที่เราเรียกว่า "ระยะการสํารวจ") การเพิ่มประสิทธิภาพแบบเบย์เซียนและเครื่องมือที่คล้ายกันเหมาะสําหรับระยะการใช้ประโยชน์มากกว่า การค้นหาแบบเกือบสุ่มซึ่งอิงตามลำดับความคลาดเคลื่อนต่ำแบบสุ่มสามารถอธิบายได้ว่าเป็น "การค้นหาตารางกริดแบบสุ่มและกระจัดกระจาย" เนื่องจากจะสุ่มสำรวจพื้นที่การค้นหาหนึ่งๆ และกระจายจุดค้นหามากกว่าการค้นหาแบบสุ่ม
ข้อดีของการค้นหาแบบเกือบสุ่มเหนือเครื่องมือเพิ่มประสิทธิภาพแบบกล่องดำที่ซับซ้อนกว่า (เช่น การเพิ่มประสิทธิภาพแบบเบย์เซียน อัลกอริทึมวิวัฒนาการ) ประกอบด้วย
- การสุ่มตัวอย่างพื้นที่การค้นหาแบบไม่ปรับเปลี่ยนช่วยให้คุณเปลี่ยนวัตถุประสงค์ในการปรับแต่งในการวิเคราะห์ผลการตรวจสอบย้อนหลังได้โดยไม่ต้องทำการทดสอบอีกครั้ง ตัวอย่างเช่น โดยทั่วไปเราต้องการค้นหาการทดสอบที่ดีที่สุดในแง่ของข้อผิดพลาดในการตรวจสอบที่ทำได้ ณ จุดใดก็ได้ในการฝึก อย่างไรก็ตาม ลักษณะการค้นหาแบบไม่ปรับเปลี่ยนตามข้อมูลที่มีอยู่ของการค้นหาแบบเกือบสุ่มช่วยให้ค้นหาการทดสอบที่ดีที่สุดได้ โดยอิงตามข้อผิดพลาดในการตรวจสอบขั้นสุดท้าย ข้อผิดพลาดในการฝึก หรือเมตริกการประเมินทางเลือกบางอย่างโดยไม่ต้องทำการทดสอบซ้ำ
- การค้นหาแบบเกือบสุ่มจะทํางานอย่างสม่ำเสมอและทําซ้ำได้ทางสถิติ คุณควรทําซ้ำการศึกษาจาก 6 เดือนที่ผ่านมาได้แม้ว่าจะมีการเปลี่ยนแปลงการใช้งานอัลกอริทึมการค้นหา ตราบใดที่ยังคงรักษาพร็อพเพอร์ตี้แบบเดียวกันไว้ หากใช้ซอฟต์แวร์การเพิ่มประสิทธิภาพแบบเบย์เซียนที่ซับซ้อน การใช้งานอาจเปลี่ยนแปลงในลักษณะที่สําคัญระหว่างเวอร์ชันต่างๆ ซึ่งทําให้สร้างการค้นหาแบบเก่าได้ยากขึ้นมาก บางครั้งคุณอาจไม่สามารถเปลี่ยนกลับไปใช้การติดตั้งใช้งานเวอร์ชันเก่าได้ (เช่น หากเครื่องมือเพิ่มประสิทธิภาพทํางานเป็นบริการ)
- การสำรวจพื้นที่การค้นหาอย่างสม่ำเสมอช่วยให้เราอนุมานเกี่ยวกับผลการค้นหาและสิ่งที่ผลการค้นหาอาจแนะนำเกี่ยวกับพื้นที่การค้นหาได้ง่ายขึ้น เช่น หากจุดที่ดีที่สุดในการเข้าชมการค้นหาแบบเกือบสุ่มอยู่ตรงขอบเขตของพื้นที่การค้นหา นี่เป็นสัญญาณที่ดี (แต่ไม่ใช่สัญญาณที่เชื่อถือได้เสมอไป) ที่ควรเปลี่ยนขอบเขตของพื้นที่การค้นหา อย่างไรก็ตาม อัลกอริทึมการเพิ่มประสิทธิภาพแบบกล่องดำแบบปรับเปลี่ยนได้อาจไม่ได้คำนึงถึงช่วงกลางของพื้นที่การค้นหาเนื่องจากช่วงทดลองช่วงแรกๆ ที่ไม่ประสบความสำเร็จ แม้ว่าพื้นที่ดังกล่าวจะมีจุดที่มีประสิทธิภาพเท่ากันก็ตาม เนื่องจากความไม่สม่ำเสมอแบบนี้เองที่อัลกอริทึมการเพิ่มประสิทธิภาพที่ดีต้องใช้เพื่อเร่งความเร็วการค้นหา
- การใช้การทดสอบจํานวนต่างกันแบบขนานกับแบบตามลําดับไม่ได้ให้ผลลัพธ์ทางสถิติที่แตกต่างกันเมื่อใช้การค้นหาแบบเกือบสุ่ม (หรืออัลกอริทึมการค้นหาอื่นๆ ที่ไม่ปรับเปลี่ยน) ซึ่งต่างจากอัลกอริทึมแบบปรับเปลี่ยน
- อัลกอริทึมการค้นหาที่ซับซ้อนมากขึ้นอาจจัดการจุดที่ไม่สามารถทำได้อย่างไม่ถูกต้องเสมอไป โดยเฉพาะหากไม่ได้ออกแบบมาโดยคำนึงถึงการปรับแต่งไฮเปอร์พารามิเตอร์ของเครือข่ายประสาท
- การค้นหาแบบเกือบสุ่มนั้นใช้งานง่ายและมีประสิทธิภาพดีเมื่อการทดสอบการปรับแต่งหลายรายการทํางานพร้อมกัน จากประสบการณ์1 อัลกอริทึมแบบปรับเปลี่ยนได้นั้นทํางานได้ยากมากเมื่อเทียบกับการค้นหาแบบเกือบสุ่มที่มีงบประมาณ 2 เท่า โดยเฉพาะเมื่อต้องทำการทดสอบหลายรายการพร้อมกัน (และโอกาสที่จะใช้ผลการทดสอบก่อนหน้าเมื่อเริ่มการทดสอบใหม่มีน้อยมาก) หากไม่มีความเชี่ยวชาญด้านการเพิ่มประสิทธิภาพแบบเบย์เซียนและวิธีการเพิ่มประสิทธิภาพแบบกล่องดำขั้นสูงอื่นๆ คุณอาจไม่ได้รับประโยชน์ที่ควรจะได้รับ การเปรียบเทียบอัลกอริทึมการเพิ่มประสิทธิภาพแบบขั้นสูงซึ่งทำงานแบบไม่เปิดเผยข้อมูลในสภาพการปรับแต่งการเรียนรู้เชิงลึกที่สมจริงนั้นเป็นเรื่องยาก อัลกอริทึมเหล่านี้เป็นหัวข้อการวิจัยที่ได้รับความนิยมในปัจจุบัน และอัลกอริทึมที่ซับซ้อนมากขึ้นก็อาจก่อให้เกิดปัญหาสำหรับผู้ใช้ที่ไม่มีประสบการณ์ ผู้เชี่ยวชาญด้านวิธีการเหล่านี้สามารถได้ผลลัพธ์ที่ดี แต่ในกรณีที่มีการขนานกันสูง พื้นที่การค้นหาและงบประมาณมักจะมีความสำคัญมากกว่า
อย่างไรก็ตาม หากทรัพยากรการประมวลผลของคุณอนุญาตให้ทำการทดสอบแบบขนานได้เพียงไม่กี่รายการ และคุณมีเวลาทำการทดสอบหลายรายการตามลำดับได้ การเพิ่มประสิทธิภาพแบบเบย์เซียนจะน่าสนใจกว่ามาก แม้ว่าจะทำให้การตีความผลลัพธ์การปรับแต่งยากขึ้นก็ตาม
ฉันจะดูการใช้งานการค้นหาแบบเกือบสุ่มได้จากที่ใด
Vizier แบบโอเพนซอร์สมีการใช้งานการค้นหาแบบเกือบสุ่ม ตั้งค่า algorithm="QUASI_RANDOM_SEARCH"
ในตัวอย่างการใช้งาน Vizier นี้ การใช้งานทางเลือกมีอยู่ในตัวอย่างการสํารวจไฮเปอร์พารามิเตอร์นี้ การใช้งานทั้ง 2 รูปแบบนี้จะสร้างลําดับ Halton สําหรับพื้นที่การค้นหาหนึ่งๆ (มีไว้เพื่อใช้ลําดับ Halton ที่เลื่อนและสลับที่ตามที่แนะนําในไฮเปอร์พารามิเตอร์สําคัญ: ไม่สุ่ม ไม่ร้องไห้)
หากไม่มีอัลกอริทึมการค้นหาแบบกึ่งสุ่มที่อิงตามลําดับความคลาดเคลื่อนต่ำ คุณอาจใช้การค้นหาแบบสุ่มเทียมแทนได้ แม้ว่าวิธีนี้อาจมีประสิทธิภาพน้อยกว่าเล็กน้อย ในมิติข้อมูล 1-2 รายการ ระบบจะยอมรับการค้นหาตารางกริดด้วย แต่ไม่ยอมรับในมิติข้อมูลระดับสูงขึ้น (ดู Bergstra & Bengio, 2012)
ต้องทำการทดสอบกี่ครั้งจึงจะได้ผลลัพธ์ที่ดีจากการค้นหาแบบเกือบสุ่ม
โดยทั่วไปแล้ว คุณจะไม่สามารถระบุจํานวนการทดสอบที่จําเป็นเพื่อให้ได้ผลลัพธ์จากการค้นหาแบบเกือบสุ่ม แต่คุณสามารถดูตัวอย่างที่เฉพาะเจาะจงได้ ดังที่รูปที่ 3 แสดง จำนวนการทดสอบในการศึกษาอาจมีผลอย่างมากต่อผลลัพธ์

รูปที่ 3: ResNet-50 ที่ปรับแต่งใน ImageNet ด้วยการทดสอบ 100 ครั้ง โดยใช้การบูตสแ trapping ระบบจะจําลองงบประมาณการปรับแต่งจํานวนต่างๆ ระบบจะแสดงผังกล่องของประสิทธิภาพที่ดีที่สุดสําหรับงบประมาณการทดสอบแต่ละรายการ
โปรดสังเกตสิ่งต่อไปนี้เกี่ยวกับรูปที่ 3
- ช่วงระหว่างกลุ่มกลางเมื่อสุ่มตัวอย่าง 6 ครั้งจะใหญ่กว่ามากเมื่อสุ่มตัวอย่าง 20 ครั้ง
- แม้จะมีการทดสอบ 20 ครั้ง แต่ความแตกต่างระหว่างการศึกษาที่โชคดีและโชคร้ายมากก็อาจมากกว่าความผันผวนทั่วไประหว่างการฝึกโมเดลนี้ซ้ำด้วยข้อมูลสุ่มเริ่มต้นที่แตกต่างกัน โดยมีไฮเปอร์พารามิเตอร์แบบคงที่ ซึ่งสำหรับปริมาณงานนี้อาจอยู่ที่ประมาณ +/- 0.1% ในอัตราข้อผิดพลาดในการทดสอบ ~23%
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-07-27 UTC
[null,null,["อัปเดตล่าสุด 2025-07-27 UTC"],[[["\u003cp\u003eQuasi-random search, akin to "jittered, shuffled grid search," offers consistent exploration of hyperparameter search spaces, aiding in insightful analysis and reproducibility.\u003c/p\u003e\n"],["\u003cp\u003eIts non-adaptive nature enables flexible post hoc analysis without rerunning experiments, unlike adaptive methods like Bayesian optimization.\u003c/p\u003e\n"],["\u003cp\u003eWhile Bayesian optimization excels with sequential trials, quasi-random search shines in high-parallelism scenarios, often outperforming adaptive methods with double its budget.\u003c/p\u003e\n"],["\u003cp\u003eQuasi-random search facilitates easier interpretation of results and identification of potential search space boundary issues.\u003c/p\u003e\n"],["\u003cp\u003eAlthough the required number of trials varies depending on the problem, studies show significant impact on results, highlighting the importance of adequate budget allocation.\u003c/p\u003e\n"]]],[],null,["# Quasi-random search\n\nThis unit focuses on quasi-random search.\n\nWhy use quasi-random search?\n----------------------------\n\nQuasi-random search (based on low-discrepancy sequences) is our preference\nover fancier blackbox optimization tools when used as part of an iterative\ntuning process intended to maximize insight into the tuning problem (what\nwe refer to as the \"exploration phase\"). Bayesian optimization and similar\ntools are more appropriate for the exploitation phase.\nQuasi-random search based on randomly shifted low-discrepancy sequences can\nbe thought of as \"jittered, shuffled grid search\", since it uniformly, but\nrandomly, explores a given search space and spreads out the search points\nmore than random search.\n\nThe advantages of quasi-random search over more sophisticated blackbox\noptimization tools (e.g. Bayesian optimization, evolutionary algorithms)\ninclude:\n\n- Sampling the search space non-adaptively makes it possible to change the tuning objective in post hoc analysis without rerunning experiments. For example, we usually want to find the best trial in terms of validation error achieved at any point in training. However, the non-adaptive nature of quasi-random search makes it possible to find the best trial based on final validation error, training error, or some alternative evaluation metric without rerunning any experiments.\n- Quasi-random search behaves in a consistent and statistically reproducible way. It should be possible to reproduce a study from six months ago even if the implementation of the search algorithm changes, as long as it maintains the same uniformity properties. If using sophisticated Bayesian optimization software, the implementation might change in an important way between versions, making it much harder to reproduce an old search. It isn't always possible to roll back to an old implementation (e.g. if the optimization tool is run as a service).\n- Its uniform exploration of the search space makes it easier to reason about the results and what they might suggest about the search space. For example, if the best point in the traversal of quasi-random search is at the boundary of the search space, this is a good (but not foolproof) signal that the search space bounds should be changed. However, an adaptive blackbox optimization algorithm might have neglected the middle of the search space because of some unlucky early trials even if it happens to contain equally good points, since it is this exact sort of non-uniformity that a good optimization algorithm needs to employ to speed up the search.\n- Running different numbers of trials in parallel versus sequentially does not produce statistically different results when using quasi-random search (or other non-adaptive search algorithms), unlike with adaptive algorithms.\n- More sophisticated search algorithms may not always handle infeasible points correctly, especially if they aren't designed with neural network hyperparameter tuning in mind.\n- Quasi-random search is simple and works especially well when many tuning trials are running in parallel. Anecdotally^[1](#fn1)^, it is very hard for an adaptive algorithm to beat a quasi-random search that has 2X its budget, especially when many trials need to be run in parallel (and thus there are very few chances to make use of previous trial results when launching new trials). Without expertise in Bayesian optimization and other advanced blackbox optimization methods, you might not achieve the benefits they are, in principle, capable of providing. It is hard to benchmark advanced blackbox optimization algorithms in realistic deep learning tuning conditions. They are a very active area of current research, and the more sophisticated algorithms come with their own pitfalls for inexperienced users. Experts in these methods are able to get good results, but in high-parallelism conditions the search space and budget tend to matter a lot more.\n\nThat said, if your computational resources only allow a small number of\ntrials to run in parallel and you can afford to run many trials in sequence,\nBayesian optimization becomes much more attractive despite making your\ntuning results harder to interpret.\n\nWhere can I find an implementation of quasi-random search?\n----------------------------------------------------------\n\n[Open-Source Vizier](https://github.com/google/vizier) has\n[an implementation of quasi-random\nsearch](https://github.com/google/vizier/blob/main/vizier/_src/algorithms/designers/quasi_random.py).\nSet `algorithm=\"QUASI_RANDOM_SEARCH\"` in [this Vizier usage\nexample](https://oss-vizier.readthedocs.io/en/latest/guides/user/running_vizier.html).\nAn alternative implementation exists [in this hyperparameter sweeps\nexample](https://github.com/mlcommons/algorithmic-efficiency/blob/main/algorithmic_efficiency/halton.py).\nBoth of these implementations generate a Halton sequence for a given search\nspace (intended to implement a shifted, scrambled Halton sequence as\nrecommended in\n[Critical Hyper-Parameters: No Random, No\nCry](https://arxiv.org/abs/1706.03200).\n\nIf a quasi-random search algorithm based on a low-discrepancy sequence is not\navailable, it is possible to substitute pseudo random uniform search instead,\nalthough this is likely to be slightly less efficient. In 1-2 dimensions,\ngrid search is also acceptable, although not in higher dimensions. (See\n[Bergstra \\& Bengio, 2012](https://www.jmlr.org/papers/v13/bergstra12a.html)).\n\nHow many trials are needed to get good results with quasi-random search?\n------------------------------------------------------------------------\n\nThere is no way to determine how many trials are needed to get\nresults with quasi-random search in general, but you can look at\nspecific examples. As Figure 3 shows, the number of trials in a study can\nhave a substantial impact on the results:\n\n**Figure 3:** ResNet-50 tuned on ImageNet with 100 trials.\nUsing bootstrapping, different amounts of tuning budget were simulated.\nBox plots of the best performances for each trial budget are plotted.\n\n\u003cbr /\u003e\n\nNotice the following about Figure 3:\n\n- The interquartile ranges when 6 trials were sampled are much larger than when 20 trials were sampled.\n- Even with 20 trials, the difference between especially lucky and unlucky studies are likely larger than the typical variation between retrains of this model on different random seeds, with fixed hyperparameters, which for this workload might be around +/- 0.1% on a validation error rate of \\~23%.\n\n*** ** * ** ***\n\n1. Ben Recht and Kevin Jamieson\n [pointed out](http://www.argmin.net/2016/06/20/hypertuning/) how strong\n 2X-budget random search is as a baseline (the\n [Hyperband paper](https://jmlr.org/papers/volume18/16-558/16-558.pdf)\n makes similar arguments), but it is certainly possible to find search\n spaces and problems where state-of-the-art Bayesian optimization\n techniques crush random search that has 2X the budget. However, in our\n experience beating 2X-budget random search gets much harder in the\n high-parallelism regime since Bayesian optimization has no opportunity to\n observe the results of previous trials. [↩](#fnref1)"]]