{"cells":[{"metadata":{"_uuid":"9c02122ffd2a56cd4d81275a703de255bf3dcb50","_cell_guid":"1c408096-e2ed-4b1a-96dc-d97f04576a0c"},"cell_type":"markdown","source":"# Exercise Introduction\n\nTo build and test your intuition for convolutions, you will design a vertical line detector.  We'll apply it to each part of an image to create a new tensor showing where there are vertical lines.\n\n![Imgur](https://i.imgur.com/op9Maqr.png)\n\n\n\n\n---\n\n# Import Utility Functions\nWe'll use some small utilty functions to load raw image data, visualize the results and give hints on your answert, etc.  .\n"},{"metadata":{"_uuid":"1c812b255b9e577cd5f5118823ad3c7725bc8872","collapsed":true,"_cell_guid":"ee82df62-e608-4bc5-8262-f6ad4961054b","trusted":true},"cell_type":"code","source":"from learntools.deep_learning.exercise_1 import load_my_image, apply_conv_to_image, show, print_hints","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"aef8e139775e21a4e01ad07547aa83a6f3a72919","_cell_guid":"805ef092-0efe-4a85-a0df-5e5d17404469"},"cell_type":"markdown","source":"# Example Convolution: Horizontal Line Detector\nHere is the convolution you saw in the video.  It's provided here as an example, and you shouldn't need to change it."},{"metadata":{"_uuid":"c8f6a7c3503c2bcc5922b1a01000b13fcdf7055e","collapsed":true,"_cell_guid":"8b1ac6d7-521e-4591-b076-af0be8185b45","trusted":true},"cell_type":"code","source":"# Detects bright pixels over dark pixels. \nhorizontal_line_conv = [[1, 1], \n                        [-1, -1]]","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"bd7f2171bb84fa25e8a106b5834bf34ad2201d93","_cell_guid":"0ed4659f-9661-404d-8b0c-710bf4666425"},"cell_type":"markdown","source":"# Your Turn: Vertical Line Detector\n\n**Replace the question marks with numbers to make a vertical line detector and uncomment both lines of code in the cell below.**"},{"metadata":{"_uuid":"22aff839d64cc10f7d1b88a845d4eac12cdf549e","collapsed":true,"_cell_guid":"51919a23-0fa4-4d60-b616-2cb96bccf0e7","trusted":true},"cell_type":"code","source":"vertical_line_conv = [[1, -1], \n                     [1, -1]]\n#vertical line (convulation) detector","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"bdbe9e7d79d138b493886c583969da62bcdee69a","_cell_guid":"eb1d9588-cb01-45eb-a0f3-af81d4e3f164"},"cell_type":"markdown","source":"**Once you have created vertical_line_conv in the cell above, add it as an additional item to `conv_list` in the next cell. Then run that cell.**"},{"metadata":{"_uuid":"fbc4e47d0a4bb86166d858046cc7b6e65f7521e4","_cell_guid":"42ff7e62-aa38-4263-a8f5-86acaf5e82ae","trusted":true,"collapsed":true},"cell_type":"code","source":"#code identifies both horizontal andvertical lines\nconv_list = [horizontal_line_conv , vertical_line_conv]\n\noriginal_image = load_my_image()\nprint(\"Original image\")\nshow(original_image)\nfor conv in conv_list:\n    filtered_image = apply_conv_to_image(conv, original_image)\n    print(\"Output: \")\n    show(filtered_image)\n#applies both horizontal and vertiacl line (convulation) detection","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"9813c870835696f2916b93c33ccf1639bc69cf6e","_cell_guid":"182683d4-dd85-443d-b430-7c23e649112e"},"cell_type":"markdown","source":"\n**Above, you'll see the output of the horizontal line filter as well as the filter you added. If you got it right, the output of your filter will looks like this.**\n![Imgur](https://i.imgur.com/uR2ngvK.png)\n\n---\n# Keep Going\n**Now you are ready to [combine convolutions into powerful models](https://www.kaggle.com/dansbecker/building-models-from-convolutions). These models are fun to work with, so keep going.**\n\n---\n\nHave questions, comments or feedback?  Bring them to [the Learn forum](https://www.kaggle.com/learn-forum)\n\n**[Deep Learning Track Home](https://www.kaggle.com/education/deep-learning)**"}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}