Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions cycle-gan/CycleGAN_Solution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,18 @@
"\n",
"## Load and Visualize the Data\n",
"\n",
"We'll first load in and visualize the training data, importing the necessary libraries to do so.\n",
"\n",
"> If you are working locally, you'll need to download the data as a zip file by [clicking here](https://s3.amazonaws.com/video.udacity-data.com/topher/2018/November/5be66e78_summer2winter-yosemite/summer2winter-yosemite.zip).\n",
"\n",
"It may be named `summer2winter-yosemite` with a dash or an underscore, so take note and make sure the below `image_dir` accordingly. Then you can proceed with the following loading code."
"We'll first load in and visualize the training data, importing the necessary libraries to do so."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"# !unzip summer2winter_yosemite.zip # can comment out after executing once"
]
},
{
Expand Down Expand Up @@ -263,7 +270,7 @@
"def scale(x, feature_range=(-1, 1)):\n",
" ''' Scale takes in an image x and returns that image, scaled\n",
" with a feature_range of pixel values from -1 to 1. \n",
" This function assumes that the input x is already scaled from 0-1.'''\n",
" This function assumes that the input x is already scaled from 0-255.'''\n",
" \n",
" # scale from 0-1 to feature_range\n",
" min, max = feature_range\n",
Expand Down Expand Up @@ -382,7 +389,8 @@
" self.conv4 = conv(conv_dim*4, conv_dim*8, 4) # (8, 8, 512)\n",
" \n",
" # Classification layer\n",
" self.conv5 = conv(conv_dim*8, 1, 4, stride=1, batch_norm=False)\n",
" self.conv5 = conv(conv_dim*8, 1, 8, stride=1, padding=0, batch_norm=False)\n",
" \n",
"\n",
" def forward(self, x):\n",
" # relu applied to all conv layers but last\n",
Expand Down Expand Up @@ -1003,7 +1011,7 @@
" return torch.mean((D_out-1)**2)\n",
"\n",
"def fake_mse_loss(D_out):\n",
" # how close is the produced output from being \"fake\"?\n",
" # how close is the produced output from being \"false\"?\n",
" return torch.mean(D_out**2)\n",
"\n",
"def cycle_consistency_loss(real_im, reconstructed_im, lambda_weight):\n",
Expand Down Expand Up @@ -1944,7 +1952,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python [default]",
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
Expand All @@ -1958,7 +1966,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
"version": "3.6.3"
}
},
"nbformat": 4,
Expand Down