Created using Colaboratory
This commit is contained in:
parent
8e30fe8d5a
commit
0bf4dc6e9f
1 changed files with 231 additions and 59 deletions
264
notebook_1.ipynb
264
notebook_1.ipynb
|
|
@ -46,23 +46,23 @@
|
||||||
"base_uri": "https://localhost:8080/",
|
"base_uri": "https://localhost:8080/",
|
||||||
"height": 136
|
"height": 136
|
||||||
},
|
},
|
||||||
"outputId": "54f06590-dcdf-4014-c0d6-de2ca5937c05"
|
"outputId": "96a9e0e9-310a-4987-fa67-b51a5f3e1e70"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"!git clone https://github.com/abdalazizrashid/AI-Feynman.git"
|
"!git clone https://github.com/abdalazizrashid/AI-Feynman.git"
|
||||||
],
|
],
|
||||||
"execution_count": 3,
|
"execution_count": 1,
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"Cloning into 'AI-Feynman'...\n",
|
"Cloning into 'AI-Feynman'...\n",
|
||||||
"remote: Enumerating objects: 46, done.\u001b[K\n",
|
"remote: Enumerating objects: 55, done.\u001b[K\n",
|
||||||
"remote: Counting objects: 100% (46/46), done.\u001b[K\n",
|
"remote: Counting objects: 100% (55/55), done.\u001b[K\n",
|
||||||
"remote: Compressing objects: 100% (29/29), done.\u001b[K\n",
|
"remote: Compressing objects: 100% (38/38), done.\u001b[K\n",
|
||||||
"remote: Total 448 (delta 22), reused 35 (delta 16), pack-reused 402\u001b[K\n",
|
"remote: Total 457 (delta 28), reused 35 (delta 16), pack-reused 402\u001b[K\n",
|
||||||
"Receiving objects: 100% (448/448), 31.30 MiB | 26.64 MiB/s, done.\n",
|
"Receiving objects: 100% (457/457), 31.31 MiB | 15.03 MiB/s, done.\n",
|
||||||
"Resolving deltas: 100% (270/270), done.\n"
|
"Resolving deltas: 100% (276/276), done.\n"
|
||||||
],
|
],
|
||||||
"name": "stdout"
|
"name": "stdout"
|
||||||
}
|
}
|
||||||
|
|
@ -75,19 +75,19 @@
|
||||||
"colab_type": "code",
|
"colab_type": "code",
|
||||||
"colab": {
|
"colab": {
|
||||||
"base_uri": "https://localhost:8080/",
|
"base_uri": "https://localhost:8080/",
|
||||||
"height": 309
|
"height": 289
|
||||||
},
|
},
|
||||||
"outputId": "434172b4-cc3c-4144-b81b-805f8a0fbd90"
|
"outputId": "aeba9212-e88b-42ef-88fc-a01ef7ccb428"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"!pip install -r AI-Feynman/requirements.txt"
|
"!pip install -r AI-Feynman/requirements.txt"
|
||||||
],
|
],
|
||||||
"execution_count": 4,
|
"execution_count": 2,
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
"Requirement already satisfied: torch in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 1)) (1.5.1+cu101)\n",
|
"Requirement already satisfied: torch in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 1)) (1.6.0+cu101)\n",
|
||||||
"Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 2)) (1.18.5)\n",
|
"Requirement already satisfied: numpy in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 2)) (1.18.5)\n",
|
||||||
"Requirement already satisfied: matplotlib in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 3)) (3.2.2)\n",
|
"Requirement already satisfied: matplotlib in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 3)) (3.2.2)\n",
|
||||||
"Requirement already satisfied: sympy in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 4)) (1.1.1)\n",
|
"Requirement already satisfied: sympy in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 4)) (1.1.1)\n",
|
||||||
|
|
@ -96,13 +96,13 @@
|
||||||
"Requirement already satisfied: sortedcontainers in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 7)) (2.2.2)\n",
|
"Requirement already satisfied: sortedcontainers in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 7)) (2.2.2)\n",
|
||||||
"Requirement already satisfied: tabulate in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 8)) (0.8.7)\n",
|
"Requirement already satisfied: tabulate in /usr/local/lib/python3.6/dist-packages (from -r AI-Feynman/requirements.txt (line 8)) (0.8.7)\n",
|
||||||
"Requirement already satisfied: future in /usr/local/lib/python3.6/dist-packages (from torch->-r AI-Feynman/requirements.txt (line 1)) (0.16.0)\n",
|
"Requirement already satisfied: future in /usr/local/lib/python3.6/dist-packages (from torch->-r AI-Feynman/requirements.txt (line 1)) (0.16.0)\n",
|
||||||
"Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/dist-packages (from matplotlib->-r AI-Feynman/requirements.txt (line 3)) (0.10.0)\n",
|
|
||||||
"Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->-r AI-Feynman/requirements.txt (line 3)) (1.2.0)\n",
|
"Requirement already satisfied: kiwisolver>=1.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->-r AI-Feynman/requirements.txt (line 3)) (1.2.0)\n",
|
||||||
"Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->-r AI-Feynman/requirements.txt (line 3)) (2.4.7)\n",
|
|
||||||
"Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->-r AI-Feynman/requirements.txt (line 3)) (2.8.1)\n",
|
"Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->-r AI-Feynman/requirements.txt (line 3)) (2.8.1)\n",
|
||||||
|
"Requirement already satisfied: cycler>=0.10 in /usr/local/lib/python3.6/dist-packages (from matplotlib->-r AI-Feynman/requirements.txt (line 3)) (0.10.0)\n",
|
||||||
|
"Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /usr/local/lib/python3.6/dist-packages (from matplotlib->-r AI-Feynman/requirements.txt (line 3)) (2.4.7)\n",
|
||||||
"Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.6/dist-packages (from sympy->-r AI-Feynman/requirements.txt (line 4)) (1.1.0)\n",
|
"Requirement already satisfied: mpmath>=0.19 in /usr/local/lib/python3.6/dist-packages (from sympy->-r AI-Feynman/requirements.txt (line 4)) (1.1.0)\n",
|
||||||
"Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.6/dist-packages (from pandas->-r AI-Feynman/requirements.txt (line 5)) (2018.9)\n",
|
"Requirement already satisfied: pytz>=2017.2 in /usr/local/lib/python3.6/dist-packages (from pandas->-r AI-Feynman/requirements.txt (line 5)) (2018.9)\n",
|
||||||
"Requirement already satisfied: six in /usr/local/lib/python3.6/dist-packages (from cycler>=0.10->matplotlib->-r AI-Feynman/requirements.txt (line 3)) (1.12.0)\n"
|
"Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.6/dist-packages (from python-dateutil>=2.1->matplotlib->-r AI-Feynman/requirements.txt (line 3)) (1.15.0)\n"
|
||||||
],
|
],
|
||||||
"name": "stdout"
|
"name": "stdout"
|
||||||
}
|
}
|
||||||
|
|
@ -113,13 +113,32 @@
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"id": "Y0gbIW5HnuQl",
|
"id": "Y0gbIW5HnuQl",
|
||||||
"colab_type": "code",
|
"colab_type": "code",
|
||||||
"colab": {}
|
"colab": {
|
||||||
|
"base_uri": "https://localhost:8080/",
|
||||||
|
"height": 153
|
||||||
|
},
|
||||||
|
"outputId": "1bb047fd-13b1-49aa-de0c-4606d3c84ec3"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"!cd /content/AI-Feynman/Code/ && ./compile.sh"
|
"!cd /content/AI-Feynman/Code/ && ./compile.sh && apt install -y parallel\n"
|
||||||
],
|
],
|
||||||
"execution_count": 5,
|
"execution_count": 14,
|
||||||
"outputs": []
|
"outputs": [
|
||||||
|
{
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Reading package lists... Done\n",
|
||||||
|
"Building dependency tree \n",
|
||||||
|
"Reading state information... Done\n",
|
||||||
|
"parallel is already the newest version (20161222-1).\n",
|
||||||
|
"The following package was automatically installed and is no longer required:\n",
|
||||||
|
" libnvidia-common-440\n",
|
||||||
|
"Use 'apt autoremove' to remove it.\n",
|
||||||
|
"0 upgraded, 0 newly installed, 0 to remove and 35 not upgraded.\n"
|
||||||
|
],
|
||||||
|
"name": "stdout"
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
|
|
@ -130,14 +149,14 @@
|
||||||
"base_uri": "https://localhost:8080/",
|
"base_uri": "https://localhost:8080/",
|
||||||
"height": 34
|
"height": 34
|
||||||
},
|
},
|
||||||
"outputId": "6ccf27cb-ff5f-46c0-ddc5-ffdb37f1fd6f"
|
"outputId": "096ee2b1-bbe7-4b1b-f743-3e56ff8fe5ad"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"import os\n",
|
"import os\n",
|
||||||
"os.chdir(\"/content/AI-Feynman/Code/\")\n",
|
"os.chdir(\"/content/AI-Feynman/Code/\")\n",
|
||||||
"print(os.getcwd())"
|
"print(os.getcwd())"
|
||||||
],
|
],
|
||||||
"execution_count": 6,
|
"execution_count": 4,
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
|
|
@ -158,7 +177,7 @@
|
||||||
"source": [
|
"source": [
|
||||||
"from S_run_aifeynman import run_aifeynman\n"
|
"from S_run_aifeynman import run_aifeynman\n"
|
||||||
],
|
],
|
||||||
"execution_count": 7,
|
"execution_count": 5,
|
||||||
"outputs": []
|
"outputs": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -816,6 +835,7 @@
|
||||||
"source": [
|
"source": [
|
||||||
"## Download the dataset from the main website\n",
|
"## Download the dataset from the main website\n",
|
||||||
"https://www.dropbox.com/s/7kgfr00qpokgz8w/Feynman_with_units.tar.gz?dl=0\n",
|
"https://www.dropbox.com/s/7kgfr00qpokgz8w/Feynman_with_units.tar.gz?dl=0\n",
|
||||||
|
"https://www.dropbox.com/s/9i05v6yw1kbkup3/Feynman_without_units.tar.gz?dl=0\n",
|
||||||
"\n",
|
"\n",
|
||||||
"The link below is no persistant you need to go to the main dropbox download link\n",
|
"The link below is no persistant you need to go to the main dropbox download link\n",
|
||||||
"and inspect the page under network tab pick the `file?_download_id=xxxxxxxx` and copy it as a \n",
|
"and inspect the page under network tab pick the `file?_download_id=xxxxxxxx` and copy it as a \n",
|
||||||
|
|
@ -831,30 +851,30 @@
|
||||||
"base_uri": "https://localhost:8080/",
|
"base_uri": "https://localhost:8080/",
|
||||||
"height": 68
|
"height": 68
|
||||||
},
|
},
|
||||||
"outputId": "d51d7838-c742-40b1-88e4-86c1df75fe88"
|
"outputId": "048b544d-2224-4a2d-b484-18c304cb110c"
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"!cd /content && curl 'https://uc860a76a6c10fa4fcb439e09b48.dl.dropboxusercontent.com/cd/0/get/A7p3n1SdaHTRnPchzaqCv4Vbrbi7OUuIUTrOlvfqPXW9FCCrR1txTQ3Z42_DE1HgyVlPwHycWPCmWQ_FTG8jFRrX9bpkfmGWBVecRebjYc7zvQ/file?_download_id=68389351594193992449463412208465892639976579750327831723819869052&_notify_domain=www.dropbox.com&dl=1' \\\n",
|
"!cd /content && curl 'https://uc4b304c377d76cb47fbccc918e2.dl.dropboxusercontent.com/cd/0/get/A860-WwfdpJE63yyVv70rwlAAmIJB8K8vnHiq-jv6a45vXzyK9a-6Yqb5zKfPHI50Znd3yw1rwwnGvoCMl2pLaOQm4N9gML1KP83d2OcgANC-g/file?_download_id=31784720549261183848105032197111167178761710119256631792641873289&_notify_domain=www.dropbox.com&dl=1' \\\n",
|
||||||
" -H 'authority: uc860a76a6c10fa4fcb439e09b48.dl.dropboxusercontent.com' \\\n",
|
" -H 'authority: uc4b304c377d76cb47fbccc918e2.dl.dropboxusercontent.com' \\\n",
|
||||||
" -H 'upgrade-insecure-requests: 1' \\\n",
|
" -H 'upgrade-insecure-requests: 1' \\\n",
|
||||||
" -H 'dnt: 1' \\\n",
|
" -H 'dnt: 1' \\\n",
|
||||||
" -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36' \\\n",
|
" -H 'user-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.89 Safari/537.36' \\\n",
|
||||||
" -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \\\n",
|
" -H 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9' \\\n",
|
||||||
" -H 'sec-fetch-site: cross-site' \\\n",
|
" -H 'sec-fetch-site: cross-site' \\\n",
|
||||||
" -H 'sec-fetch-mode: navigate' \\\n",
|
" -H 'sec-fetch-mode: navigate' \\\n",
|
||||||
" -H 'sec-fetch-dest: iframe' \\\n",
|
" -H 'sec-fetch-dest: iframe' \\\n",
|
||||||
" -H 'referer: https://www.dropbox.com/' \\\n",
|
" -H 'referer: https://www.dropbox.com/' \\\n",
|
||||||
" -H 'accept-language: en-US,en;q=0.9,ar;q=0.8' \\\n",
|
" -H 'accept-language: en-US,en;q=0.9,ar;q=0.8,ru;q=0.7' \\\n",
|
||||||
" --compressed > with_units.gz"
|
" --compressed > with_units.gz"
|
||||||
],
|
],
|
||||||
"execution_count": 11,
|
"execution_count": 6,
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
"text": [
|
"text": [
|
||||||
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
|
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
|
||||||
" Dload Upload Total Spent Left Speed\n",
|
" Dload Upload Total Spent Left Speed\n",
|
||||||
"100 3911M 100 3911M 0 0 52.5M 0 0:01:14 0:01:14 --:--:-- 50.5M\n"
|
"100 1661M 100 1661M 0 0 17.0M 0 0:01:37 0:01:37 --:--:-- 17.6M\n"
|
||||||
],
|
],
|
||||||
"name": "stdout"
|
"name": "stdout"
|
||||||
}
|
}
|
||||||
|
|
@ -870,7 +890,7 @@
|
||||||
"source": [
|
"source": [
|
||||||
"!cd /content && tar -xzf with_units.gz && cd /content/AI-Feynman/Code"
|
"!cd /content && tar -xzf with_units.gz && cd /content/AI-Feynman/Code"
|
||||||
],
|
],
|
||||||
"execution_count": 12,
|
"execution_count": 7,
|
||||||
"outputs": []
|
"outputs": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -900,7 +920,7 @@
|
||||||
" \"test_percentage\" : 0,\n",
|
" \"test_percentage\" : 0,\n",
|
||||||
"}"
|
"}"
|
||||||
],
|
],
|
||||||
"execution_count": 13,
|
"execution_count": null,
|
||||||
"outputs": []
|
"outputs": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -912,28 +932,42 @@
|
||||||
},
|
},
|
||||||
"source": [
|
"source": [
|
||||||
"import logging\n",
|
"import logging\n",
|
||||||
|
"import argparse\n",
|
||||||
"import pathlib\n",
|
"import pathlib\n",
|
||||||
|
"import os\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
|
"from threading import active_count\n",
|
||||||
|
"from multiprocessing import Pool\n",
|
||||||
|
"from multiprocessing.pool import ThreadPool\n",
|
||||||
"from random import shuffle\n",
|
"from random import shuffle\n",
|
||||||
"from tabulate import tabulate\n",
|
"from tabulate import tabulate\n",
|
||||||
"from pathlib import Path\n",
|
"from pathlib import Path\n",
|
||||||
|
"from functools import partial\n",
|
||||||
|
"\n",
|
||||||
"\n",
|
"\n",
|
||||||
"from S_run_aifeynman import run_aifeynman\n",
|
"from S_run_aifeynman import run_aifeynman\n",
|
||||||
"\n",
|
"\n",
|
||||||
"\n",
|
"_CFG = {\n",
|
||||||
|
" \"dataset_path\" : \"../../Feynman_without_units/\",\n",
|
||||||
|
" \"operations_file\" : \"./14ops.txt\",\n",
|
||||||
|
" \"polynomial_degree\" : 3,\n",
|
||||||
|
" \"number_of_epochs\" : 500,\n",
|
||||||
|
" \"bruteforce_time\" : 60,\n",
|
||||||
|
" \"test_percentage\" : 0,\n",
|
||||||
|
"}\n",
|
||||||
"\n",
|
"\n",
|
||||||
"class RunAll:\n",
|
"class RunAll:\n",
|
||||||
" \"\"\"\n",
|
" \"\"\"\n",
|
||||||
" Run the solver on the whole dataset\n",
|
" Run the solver on the whole dataset\n",
|
||||||
" \"\"\"\n",
|
" \"\"\"\n",
|
||||||
"\n",
|
"\n",
|
||||||
" def __init__(self, *, cfg):\n",
|
" def __init__(self, *, cfg=_CFG):\n",
|
||||||
" logging.basicConfig(filename=\"output.log\", level=logging.DEBUG)\n",
|
" logging.basicConfig(filename=\"output_no_units_parallel.log\", level=logging.DEBUG)\n",
|
||||||
" self.cfg = cfg\n",
|
" self.cfg = cfg\n",
|
||||||
" self.results = {}\n",
|
" self.results = {}\n",
|
||||||
" self.run_solver()\n",
|
"\n",
|
||||||
" self.print_results()\n",
|
|
||||||
" \n",
|
|
||||||
" \n",
|
" \n",
|
||||||
" def print_results(self):\n",
|
" def print_results(self):\n",
|
||||||
" table = []\n",
|
" table = []\n",
|
||||||
|
|
@ -949,13 +983,20 @@
|
||||||
" ],\n",
|
" ],\n",
|
||||||
" )\n",
|
" )\n",
|
||||||
" )\n",
|
" )\n",
|
||||||
"\n",
|
" \n",
|
||||||
" def run_solver(self):\n",
|
" def run_solver(self, dirs=None):\n",
|
||||||
|
" if not dirs:\n",
|
||||||
" path = Path(self.cfg[\"dataset_path\"])\n",
|
" path = Path(self.cfg[\"dataset_path\"])\n",
|
||||||
" dirs = list(path.iterdir())\n",
|
" dirs = list(path.iterdir())\n",
|
||||||
" shuffle(dirs) # Shuffle to sample a different file each time\n",
|
" shuffle(dirs) # Shuffle to sample a different file each time\n",
|
||||||
" for child in dirs:\n",
|
" \n",
|
||||||
" print(child)\n",
|
" else:\n",
|
||||||
|
" path=Path(self.cfg[\"dataset_path\"])\n",
|
||||||
|
" child = dirs\n",
|
||||||
|
" \n",
|
||||||
|
" \n",
|
||||||
|
"\n",
|
||||||
|
" print(f\"Process PID: {os.getpid()} ---------------- Number of threads: {active_count()}\" )\n",
|
||||||
" self.results[str(child).split(\"/\")[-1]] = run_aifeynman(\n",
|
" self.results[str(child).split(\"/\")[-1]] = run_aifeynman(\n",
|
||||||
" pathdir=str(path.resolve()) + \"/\",\n",
|
" pathdir=str(path.resolve()) + \"/\",\n",
|
||||||
" filename=str(child).split(\"/\")[-1],\n",
|
" filename=str(child).split(\"/\")[-1],\n",
|
||||||
|
|
@ -968,13 +1009,144 @@
|
||||||
" )\n",
|
" )\n",
|
||||||
"\n",
|
"\n",
|
||||||
" logging.info(self.results)\n",
|
" logging.info(self.results)\n",
|
||||||
" print(\"#\"*120)\n",
|
" print(\"@\"*120)\n",
|
||||||
" print(self.results)\n",
|
" print(\"@\"*120)\n",
|
||||||
" break\n"
|
"\n",
|
||||||
|
" self.print_results()\n",
|
||||||
|
"\n"
|
||||||
],
|
],
|
||||||
"execution_count": 25,
|
"execution_count": 46,
|
||||||
"outputs": []
|
"outputs": []
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"metadata": {
|
||||||
|
"id": "GRh1Ld01UknX",
|
||||||
|
"colab_type": "code",
|
||||||
|
"colab": {}
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"def get_files(path: str, chunks=None):\n",
|
||||||
|
" dirs = list(Path(path).iterdir())\n",
|
||||||
|
" dirs = [file.name for file in dirs if not (str(file).endswith(\"test\") or str(file).endswith(\"train\"))]\n",
|
||||||
|
" if chunks:\n",
|
||||||
|
" for i in range(0, len(dirs), chunks):\n",
|
||||||
|
" yield dirs[i : i + chunks]\n",
|
||||||
|
" yield dirs\n",
|
||||||
|
"\n",
|
||||||
|
"files = list(get_files(Path(\"/content/Feynman_without_units\")))"
|
||||||
|
],
|
||||||
|
"execution_count": 47,
|
||||||
|
"outputs": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"metadata": {
|
||||||
|
"id": "XAHCWx4BUWd1",
|
||||||
|
"colab_type": "code",
|
||||||
|
"colab": {
|
||||||
|
"base_uri": "https://localhost:8080/",
|
||||||
|
"height": 579
|
||||||
|
},
|
||||||
|
"outputId": "ba32a0e8-467c-4872-f2d9-2789b51e77ad"
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"%%time\n",
|
||||||
|
"\n",
|
||||||
|
"solver = RunAll().run_solver\n",
|
||||||
|
"path = Path(_CFG[\"dataset_path\"])\n",
|
||||||
|
"#dirs = list(path.iterdir())\n",
|
||||||
|
"#chunked_dirs = list(get_files(dirs, chunks=24))\n",
|
||||||
|
"# print(chunked_dirs[0], len(chunked_dirs[0]))\n",
|
||||||
|
"# for dd in chunked_dirs:\n",
|
||||||
|
"# pool = Pool(len(dd))\n",
|
||||||
|
"# print(dd, len(dd))\n",
|
||||||
|
"# pool.map(print, dd)\n",
|
||||||
|
"# pool.map(solver, dd)\n",
|
||||||
|
"# pool.close()\n",
|
||||||
|
"\n",
|
||||||
|
"solver(files[-1][-1])\n"
|
||||||
|
],
|
||||||
|
"execution_count": 48,
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Process PID: 119 ---------------- Number of threads: 4\n",
|
||||||
|
"Checking for brute force + \n",
|
||||||
|
"\n",
|
||||||
|
"Checking for brute force * \n",
|
||||||
|
"\n",
|
||||||
|
"Checking polyfit \n",
|
||||||
|
"\n",
|
||||||
|
"Complexity RMSE Expression\n",
|
||||||
|
"Checking for symmetry \n",
|
||||||
|
" III.7.38_train\n"
|
||||||
|
],
|
||||||
|
"name": "stdout"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"output_type": "error",
|
||||||
|
"ename": "TypeError",
|
||||||
|
"evalue": "ignored",
|
||||||
|
"traceback": [
|
||||||
|
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
||||||
|
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
|
||||||
|
"\u001b[0;32m<ipython-input-48-02549138a745>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mget_ipython\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun_cell_magic\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'time'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m''\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'\\nsolver = RunAll().run_solver\\npath = Path(_CFG[\"dataset_path\"])\\n#dirs = list(path.iterdir())\\n#chunked_dirs = list(get_files(dirs, chunks=24))\\n# print(chunked_dirs[0], len(chunked_dirs[0]))\\n# for dd in chunked_dirs:\\n# pool = Pool(len(dd))\\n# print(dd, len(dd))\\n# pool.map(print, dd)\\n# pool.map(solver, dd)\\n# pool.close()\\n\\nsolver(files[-1][-1])'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
|
||||||
|
"\u001b[0;32m/usr/local/lib/python3.6/dist-packages/IPython/core/interactiveshell.py\u001b[0m in \u001b[0;36mrun_cell_magic\u001b[0;34m(self, magic_name, line, cell)\u001b[0m\n\u001b[1;32m 2115\u001b[0m \u001b[0mmagic_arg_s\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvar_expand\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstack_depth\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2116\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbuiltin_trap\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2117\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmagic_arg_s\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcell\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2118\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2119\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||||
|
"\u001b[0;32m<decorator-gen-60>\u001b[0m in \u001b[0;36mtime\u001b[0;34m(self, line, cell, local_ns)\u001b[0m\n",
|
||||||
|
"\u001b[0;32m/usr/local/lib/python3.6/dist-packages/IPython/core/magic.py\u001b[0m in \u001b[0;36m<lambda>\u001b[0;34m(f, *a, **k)\u001b[0m\n\u001b[1;32m 186\u001b[0m \u001b[0;31m# but it's overkill for just that one bit of state.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 187\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mmagic_deco\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 188\u001b[0;31m \u001b[0mcall\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mlambda\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 189\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 190\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mcallable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||||
|
"\u001b[0;32m/usr/local/lib/python3.6/dist-packages/IPython/core/magics/execution.py\u001b[0m in \u001b[0;36mtime\u001b[0;34m(self, line, cell, local_ns)\u001b[0m\n\u001b[1;32m 1191\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1192\u001b[0m \u001b[0mst\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mclock2\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1193\u001b[0;31m \u001b[0mexec\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcode\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mglob\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlocal_ns\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1194\u001b[0m \u001b[0mend\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mclock2\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1195\u001b[0m \u001b[0mout\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||||
|
"\u001b[0;32m<timed exec>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n",
|
||||||
|
"\u001b[0;32m<ipython-input-46-ca7f84307189>\u001b[0m in \u001b[0;36mrun_solver\u001b[0;34m(self, dirs)\u001b[0m\n\u001b[1;32m 73\u001b[0m \u001b[0mNN_epochs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcfg\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"number_of_epochs\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 74\u001b[0m \u001b[0mvars_name\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 75\u001b[0;31m \u001b[0mtest_percentage\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcfg\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m\"test_percentage\"\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 76\u001b[0m )\n\u001b[1;32m 77\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||||
|
"\u001b[0;32m/content/AI-Feynman/Code/S_run_aifeynman.py\u001b[0m in \u001b[0;36mrun_aifeynman\u001b[0;34m(pathdir, filename, BF_try_time, BF_ops_file_type, polyfit_deg, NN_epochs, vars_name, test_percentage)\u001b[0m\n\u001b[1;32m 163\u001b[0m \u001b[0mPA\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mParetoSet\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 164\u001b[0m \u001b[0;31m# Run the code on the train data\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 165\u001b[0;31m \u001b[0mPA\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mrun_AI_all\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpathdir\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mfilename\u001b[0m\u001b[0;34m+\u001b[0m\u001b[0;34m\"_train\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mBF_try_time\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mBF_ops_file_type\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpolyfit_deg\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mNN_epochs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mPA\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mPA\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 166\u001b[0m \u001b[0mPA_list\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mPA\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_pareto_points\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 167\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||||
|
"\u001b[0;32m/content/AI-Feynman/Code/S_run_aifeynman.py\u001b[0m in \u001b[0;36mrun_AI_all\u001b[0;34m(pathdir, filename, BF_try_time, BF_ops_file_type, polyfit_deg, NN_epochs, PA)\u001b[0m\n\u001b[1;32m 53\u001b[0m \u001b[0;31m# check if the NN is trained. If it is not, train it on the data.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 54\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Checking for symmetry \\n\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfilename\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 55\u001b[0;31m \u001b[0;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m<\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 56\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Just one variable!\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 57\u001b[0m \u001b[0;32mpass\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
||||||
|
"\u001b[0;31mTypeError\u001b[0m: object of type 'numpy.float64' has no len()"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"metadata": {
|
||||||
|
"id": "aVvrF83iPnuL",
|
||||||
|
"colab_type": "code",
|
||||||
|
"colab": {
|
||||||
|
"base_uri": "https://localhost:8080/",
|
||||||
|
"height": 306
|
||||||
|
},
|
||||||
|
"outputId": "5936cca3-9a00-4657-d382-99613c0d496a"
|
||||||
|
},
|
||||||
|
"source": [
|
||||||
|
"!parallel"
|
||||||
|
],
|
||||||
|
"execution_count": 16,
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Academic tradition requires you to cite works you base your article on.\n",
|
||||||
|
"When using programs that use GNU Parallel to process data for publication\n",
|
||||||
|
"please cite:\n",
|
||||||
|
"\n",
|
||||||
|
" O. Tange (2011): GNU Parallel - The Command-Line Power Tool,\n",
|
||||||
|
" ;login: The USENIX Magazine, February 2011:42-47.\n",
|
||||||
|
"\n",
|
||||||
|
"This helps funding further development; AND IT WON'T COST YOU A CENT.\n",
|
||||||
|
"If you pay 10000 EUR you should feel free to use GNU Parallel without citing.\n",
|
||||||
|
"\n",
|
||||||
|
"To silence this citation notice: run 'parallel --citation'.\n",
|
||||||
|
"\n",
|
||||||
|
"parallel: Warning: Input is read from the terminal. You either know what you\n",
|
||||||
|
"parallel: Warning: are doing (in which case: YOU ARE AWESOME!) or you forgot\n",
|
||||||
|
"parallel: Warning: ::: or :::: or to pipe data into parallel. If so\n",
|
||||||
|
"parallel: Warning: consider going through the tutorial: man parallel_tutorial\n",
|
||||||
|
"parallel: Warning: Press CTRL-D to exit.\n"
|
||||||
|
],
|
||||||
|
"name": "stdout"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"metadata": {
|
"metadata": {
|
||||||
|
|
@ -991,7 +1163,7 @@
|
||||||
"RunAll(cfg=_CFG)\n",
|
"RunAll(cfg=_CFG)\n",
|
||||||
" "
|
" "
|
||||||
],
|
],
|
||||||
"execution_count": 26,
|
"execution_count": null,
|
||||||
"outputs": [
|
"outputs": [
|
||||||
{
|
{
|
||||||
"output_type": "stream",
|
"output_type": "stream",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue