|
4836 | 4836 | "spot_tuner = load_and_run_spot_python_experiment(\"spot_000_experiment.pickle\")" |
4837 | 4837 | ] |
4838 | 4838 | }, |
| 4839 | + { |
| 4840 | + "cell_type": "markdown", |
| 4841 | + "metadata": {}, |
| 4842 | + "source": [ |
| 4843 | + "# Lightning " |
| 4844 | + ] |
| 4845 | + }, |
| 4846 | + { |
| 4847 | + "cell_type": "code", |
| 4848 | + "execution_count": 13, |
| 4849 | + "metadata": {}, |
| 4850 | + "outputs": [], |
| 4851 | + "source": [ |
| 4852 | + "def _generate_div2_list(n, n_min) -> list:\n", |
| 4853 | + " \"\"\"\n", |
| 4854 | + " Generate a list of numbers from n to n_min (inclusive) by dividing n by 2\n", |
| 4855 | + " until the result is less than n_min.\n", |
| 4856 | + " This function starts with n and keeps dividing it by 2 until n_min is reached.\n", |
| 4857 | + " The number of times each value is added to the list is determined by n // current.\n", |
| 4858 | + "\n", |
| 4859 | + " Args:\n", |
| 4860 | + " n (int): The number to start with.\n", |
| 4861 | + " n_min (int): The minimum number to stop at.\n", |
| 4862 | + "\n", |
| 4863 | + " Returns:\n", |
| 4864 | + " list: A list of numbers from n to n_min (inclusive).\n", |
| 4865 | + "\n", |
| 4866 | + " Examples:\n", |
| 4867 | + " _generate_div2_list(10, 1)\n", |
| 4868 | + " [10, 5, 5, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n", |
| 4869 | + " _generate_div2_list(10, 2)\n", |
| 4870 | + " [10, 5, 5, 2, 2, 2, 2, 2]\n", |
| 4871 | + " \"\"\"\n", |
| 4872 | + " result = []\n", |
| 4873 | + " current = n\n", |
| 4874 | + " repeats = 1\n", |
| 4875 | + " max_repeats = 4\n", |
| 4876 | + " while current >= n_min:\n", |
| 4877 | + " result.extend([current] * min(repeats, max_repeats))\n", |
| 4878 | + " current = current // 2\n", |
| 4879 | + " repeats = repeats + 1\n", |
| 4880 | + " return result" |
| 4881 | + ] |
| 4882 | + }, |
| 4883 | + { |
| 4884 | + "cell_type": "code", |
| 4885 | + "execution_count": 14, |
| 4886 | + "metadata": {}, |
| 4887 | + "outputs": [ |
| 4888 | + { |
| 4889 | + "data": { |
| 4890 | + "text/plain": [ |
| 4891 | + "[10, 5, 5]" |
| 4892 | + ] |
| 4893 | + }, |
| 4894 | + "execution_count": 14, |
| 4895 | + "metadata": {}, |
| 4896 | + "output_type": "execute_result" |
| 4897 | + } |
| 4898 | + ], |
| 4899 | + "source": [ |
| 4900 | + "_generate_div2_list(10, 3)" |
| 4901 | + ] |
| 4902 | + }, |
| 4903 | + { |
| 4904 | + "cell_type": "code", |
| 4905 | + "execution_count": 17, |
| 4906 | + "metadata": {}, |
| 4907 | + "outputs": [ |
| 4908 | + { |
| 4909 | + "data": { |
| 4910 | + "text/plain": [ |
| 4911 | + "[128, 64, 64, 32, 32, 32]" |
| 4912 | + ] |
| 4913 | + }, |
| 4914 | + "execution_count": 17, |
| 4915 | + "metadata": {}, |
| 4916 | + "output_type": "execute_result" |
| 4917 | + } |
| 4918 | + ], |
| 4919 | + "source": [ |
| 4920 | + "_generate_div2_list(128, 32)" |
| 4921 | + ] |
| 4922 | + }, |
4839 | 4923 | { |
4840 | 4924 | "cell_type": "code", |
4841 | 4925 | "execution_count": null, |
|
0 commit comments