Skip to content

Commit a7a96c2

Browse files
committed
fixing todos
1 parent 0006b50 commit a7a96c2

File tree

1 file changed

+58
-26
lines changed

1 file changed

+58
-26
lines changed

lab3/solutions/RL_Solution.ipynb

Lines changed: 58 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,10 @@
249249
" # First Dense layer\n",
250250
" tf.keras.layers.Dense(units=32, activation='relu'),\n",
251251
"\n",
252-
" # TODO: Define the last Dense layer, which will provide the network's output.\n",
253-
" # Think about the space the agent needs to act in!\n",
252+
" ''' TODO: Define the last Dense layer, which will provide the network's output.\n",
253+
" # Think about the space the agent needs to act in! '''\n",
254254
" tf.keras.layers.Dense(units=n_actions, activation=None) # TODO\n",
255-
" # [TODO Dense layer to output action probabilities]\n",
255+
" # ['''TODO''' Dense layer to output action probabilities]\n",
256256
" ])\n",
257257
" return model\n",
258258
"\n",
@@ -720,12 +720,46 @@
720720
},
721721
{
722722
"cell_type": "code",
723-
"execution_count": null,
723+
"execution_count": 3,
724724
"metadata": {
725725
"scrolled": true,
726-
"id": "JrTpTBJsJ9Bp"
726+
"colab": {
727+
"base_uri": "https://localhost:8080/",
728+
"height": 530
729+
},
730+
"id": "JrTpTBJsJ9Bp",
731+
"outputId": "c6a7e93c-a9c1-4a15-b550-0dd4db94d05c"
727732
},
728-
"outputs": [],
733+
"outputs": [
734+
{
735+
"output_type": "stream",
736+
"name": "stdout",
737+
"text": [
738+
"vista_traces.zip 29%[====> ] 180.35M 68.8MB/s ^C\n",
739+
"Unzipping data...\n",
740+
"[vista_traces.zip]\n",
741+
" End-of-central-directory signature not found. Either this file is not\n",
742+
" a zipfile, or it constitutes one disk of a multi-part archive. In the\n",
743+
" latter case the central directory and zipfile comment will be found on\n",
744+
" the last disk(s) of this archive.\n",
745+
"unzip: cannot find zipfile directory in one of vista_traces.zip or\n",
746+
" vista_traces.zip.zip, and cannot find vista_traces.zip.ZIP, period.\n",
747+
"Done downloading and unzipping data!\n"
748+
]
749+
},
750+
{
751+
"output_type": "error",
752+
"ename": "NameError",
753+
"evalue": "ignored",
754+
"traceback": [
755+
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
756+
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
757+
"\u001b[0;32m<ipython-input-3-06a67e1ffe73>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0;34m\"20210726-184956_lexus_devens_center_reverse\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 13\u001b[0m ]\n\u001b[0;32m---> 14\u001b[0;31m \u001b[0mtrace_path\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrace_root\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mp\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mp\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mtrace_path\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 15\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[0;31m# Create a virtual world with VISTA, the world is defined by a series of data traces\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
758+
"\u001b[0;32m<ipython-input-3-06a67e1ffe73>\u001b[0m in \u001b[0;36m<listcomp>\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0;34m\"20210726-184956_lexus_devens_center_reverse\"\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 13\u001b[0m ]\n\u001b[0;32m---> 14\u001b[0;31m \u001b[0mtrace_path\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mos\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpath\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrace_root\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mp\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mp\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mtrace_path\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 15\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[0;31m# Create a virtual world with VISTA, the world is defined by a series of data traces\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
759+
"\u001b[0;31mNameError\u001b[0m: name 'os' is not defined"
760+
]
761+
}
762+
],
729763
"source": [
730764
"# Download and extract the data for vista (auto-skip if already downloaded)\n",
731765
"!wget -nc -q --show-progress https://www.dropbox.com/s/3qogfzuugi852du/vista_traces.zip\n",
@@ -735,8 +769,6 @@
735769
"\n",
736770
"trace_root = \"./vista_traces\"\n",
737771
"trace_path = [\n",
738-
"# \"20210726-131322_lexus_devens_center\", \n",
739-
"# \"20210726-131912_lexus_devens_center_reverse\", \n",
740772
" \"20210726-154641_lexus_devens_center\", \n",
741773
" \"20210726-155941_lexus_devens_center_reverse\", \n",
742774
" \"20210726-184624_lexus_devens_center\", \n",
@@ -1093,11 +1125,11 @@
10931125
" # First, 32 5x5 filters and 2x2 stride\n",
10941126
" Conv2D(filters=32, kernel_size=5, strides=2),\n",
10951127
"\n",
1096-
" # TODO: define convolutional layers with 48 5x5 filters and 2x2 stride\n",
1128+
" ''' TODO: define convolutional layers with 48 5x5 filters and 2x2 stride '''\n",
10971129
" Conv2D(filters=48, kernel_size=5, strides=2), # TODO\n",
10981130
" # Conv2D('''TODO'''),\n",
10991131
"\n",
1100-
" # TODO: define two convolutional layers with 64 3x3 filters and 2x2 stride\n",
1132+
" ''' TODO: define two convolutional layers with 64 3x3 filters and 2x2 stride '''\n",
11011133
" Conv2D(filters=64, kernel_size=3, strides=2), # TODO\n",
11021134
" Conv2D(filters=64, kernel_size=3, strides=2), # TODO\n",
11031135
" # Conv2D('''TODO'''),\n",
@@ -1106,10 +1138,10 @@
11061138
"\n",
11071139
" # Fully connected layer and output\n",
11081140
" Dense(units=128, activation=act),\n",
1109-
" # TODO: define the output dimension of the last Dense layer. \n",
1110-
" # Pay attention to the space the agent needs to act in.\n",
1111-
" # Remember that this model is outputing *continuous* actions, \n",
1112-
" # which take a different shape than discrete actions (like in Cartpole).\n",
1141+
" ''' TODO: define the output dimension of the last Dense layer. \n",
1142+
" Pay attention to the space the agent needs to act in.\n",
1143+
" Remember that this model is outputing *continuous* actions, \n",
1144+
" which take a different shape than discrete actions (like in Cartpole). '''\n",
11131145
" Dense(units=2, activation=None) # TODO\n",
11141146
" # Dense('''TODO''')\n",
11151147
"\n",
@@ -1200,7 +1232,7 @@
12001232
"## Training parameters ##\n",
12011233
"## Re-run this cell to restart training from scratch ##\n",
12021234
"\n",
1203-
"# TODO: Learning rate and optimizer\n",
1235+
"''' TODO: Learning rate and optimizer '''\n",
12041236
"learning_rate = 5e-4\n",
12051237
"# learning_rate = '''TODO'''\n",
12061238
"optimizer = tf.keras.optimizers.Adam(learning_rate)\n",
@@ -1256,27 +1288,27 @@
12561288
" observation = grab_and_preprocess_obs(car)\n",
12571289
"\n",
12581290
" while True:\n",
1259-
" # TODO: using the car's current observation compute the desired \n",
1260-
" # action (curvature) distribution by feeding it into our \n",
1261-
" # driving model (use the function you already built to do this!)\n",
1291+
" '''TODO: using the car's current observation compute the desired \n",
1292+
" action (curvature) distribution by feeding it into our \n",
1293+
" driving model (use the function you already built to do this!) '''\n",
12621294
" curvature_dist = run_driving_model(observation)\n",
12631295
" # curvature_dist = '''TODO'''\n",
12641296
" \n",
1265-
" # TODO: sample from the action distribution to decide how to step\n",
1266-
" # the car in the environment. You may want to check the documentation\n",
1267-
" # for tfp.distributions.Normal online. Remember that the sampled action\n",
1268-
" # should be a single scalar value after this step.\n",
1297+
" ''' TODO: sample from the action distribution to decide how to step\n",
1298+
" the car in the environment. You may want to check the documentation\n",
1299+
" for tfp.distributions.Normal online. Remember that the sampled action\n",
1300+
" should be a single scalar value after this step.'''\n",
12691301
" curvature_action = curvature_dist.sample()[0,0]\n",
12701302
" # curvature_action = '''TODO'''\n",
12711303
" \n",
12721304
" # Step the simulated car with the same action\n",
12731305
" vista_step(curvature_action)\n",
12741306
" observation = grab_and_preprocess_obs(car)\n",
12751307
" \n",
1276-
" # TODO: Compute the reward for this iteration. You define \n",
1277-
" # the reward function for this policy, start with something \n",
1278-
" # simple - for example, give a reward of 1 if the car did not \n",
1279-
" # crash and a reward of 0 if it did crash.\n",
1308+
" '''TODO: Compute the reward for this iteration. You define \n",
1309+
" the reward function for this policy, start with something \n",
1310+
" simple - for example, give a reward of 1 if the car did not \n",
1311+
" crash and a reward of 0 if it did crash.'''\n",
12801312
" reward = 1.0 if not check_crash(car) else 0.0\n",
12811313
" # reward = '''TODO'''\n",
12821314
" \n",

0 commit comments

Comments
 (0)