[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"similar-pkmital--CADL":3,"tool-pkmital--CADL":61},[4,18,26,36,44,53],{"id":5,"name":6,"github_repo":7,"description_zh":8,"stars":9,"difficulty_score":10,"last_commit_at":11,"category_tags":12,"status":17},4358,"openclaw","openclaw\u002Fopenclaw","OpenClaw 是一款专为个人打造的本地化 AI 助手，旨在让你在自己的设备上拥有完全可控的智能伙伴。它打破了传统 AI 助手局限于特定网页或应用的束缚，能够直接接入你日常使用的各类通讯渠道，包括微信、WhatsApp、Telegram、Discord、iMessage 等数十种平台。无论你在哪个聊天软件中发送消息，OpenClaw 都能即时响应，甚至支持在 macOS、iOS 和 Android 设备上进行语音交互，并提供实时的画布渲染功能供你操控。\n\n这款工具主要解决了用户对数据隐私、响应速度以及“始终在线”体验的需求。通过将 AI 部署在本地，用户无需依赖云端服务即可享受快速、私密的智能辅助，真正实现了“你的数据，你做主”。其独特的技术亮点在于强大的网关架构，将控制平面与核心助手分离，确保跨平台通信的流畅性与扩展性。\n\nOpenClaw 非常适合希望构建个性化工作流的技术爱好者、开发者，以及注重隐私保护且不愿被单一生态绑定的普通用户。只要具备基础的终端操作能力（支持 macOS、Linux 及 Windows WSL2），即可通过简单的命令行引导完成部署。如果你渴望拥有一个懂你",349277,3,"2026-04-06T06:32:30",[13,14,15,16],"Agent","开发框架","图像","数据工具","ready",{"id":19,"name":20,"github_repo":21,"description_zh":22,"stars":23,"difficulty_score":10,"last_commit_at":24,"category_tags":25,"status":17},3808,"stable-diffusion-webui","AUTOMATIC1111\u002Fstable-diffusion-webui","stable-diffusion-webui 是一个基于 Gradio 构建的网页版操作界面，旨在让用户能够轻松地在本地运行和使用强大的 Stable Diffusion 图像生成模型。它解决了原始模型依赖命令行、操作门槛高且功能分散的痛点，将复杂的 AI 绘图流程整合进一个直观易用的图形化平台。\n\n无论是希望快速上手的普通创作者、需要精细控制画面细节的设计师，还是想要深入探索模型潜力的开发者与研究人员，都能从中获益。其核心亮点在于极高的功能丰富度：不仅支持文生图、图生图、局部重绘（Inpainting）和外绘（Outpainting）等基础模式，还独创了注意力机制调整、提示词矩阵、负向提示词以及“高清修复”等高级功能。此外，它内置了 GFPGAN 和 CodeFormer 等人脸修复工具，支持多种神经网络放大算法，并允许用户通过插件系统无限扩展能力。即使是显存有限的设备，stable-diffusion-webui 也提供了相应的优化选项，让高质量的 AI 艺术创作变得触手可及。",162132,"2026-04-05T11:01:52",[14,15,13],{"id":27,"name":28,"github_repo":29,"description_zh":30,"stars":31,"difficulty_score":32,"last_commit_at":33,"category_tags":34,"status":17},1381,"everything-claude-code","affaan-m\u002Feverything-claude-code","everything-claude-code 是一套专为 AI 编程助手（如 Claude Code、Codex、Cursor 等）打造的高性能优化系统。它不仅仅是一组配置文件，而是一个经过长期实战打磨的完整框架，旨在解决 AI 代理在实际开发中面临的效率低下、记忆丢失、安全隐患及缺乏持续学习能力等核心痛点。\n\n通过引入技能模块化、直觉增强、记忆持久化机制以及内置的安全扫描功能，everything-claude-code 能显著提升 AI 在复杂任务中的表现，帮助开发者构建更稳定、更智能的生产级 AI 代理。其独特的“研究优先”开发理念和针对 Token 消耗的优化策略，使得模型响应更快、成本更低，同时有效防御潜在的攻击向量。\n\n这套工具特别适合软件开发者、AI 研究人员以及希望深度定制 AI 工作流的技术团队使用。无论您是在构建大型代码库，还是需要 AI 协助进行安全审计与自动化测试，everything-claude-code 都能提供强大的底层支持。作为一个曾荣获 Anthropic 黑客大奖的开源项目，它融合了多语言支持与丰富的实战钩子（hooks），让 AI 真正成长为懂上",160015,2,"2026-04-18T11:30:52",[14,13,35],"语言模型",{"id":37,"name":38,"github_repo":39,"description_zh":40,"stars":41,"difficulty_score":32,"last_commit_at":42,"category_tags":43,"status":17},2271,"ComfyUI","Comfy-Org\u002FComfyUI","ComfyUI 是一款功能强大且高度模块化的视觉 AI 引擎，专为设计和执行复杂的 Stable Diffusion 图像生成流程而打造。它摒弃了传统的代码编写模式，采用直观的节点式流程图界面，让用户通过连接不同的功能模块即可构建个性化的生成管线。\n\n这一设计巧妙解决了高级 AI 绘图工作流配置复杂、灵活性不足的痛点。用户无需具备编程背景，也能自由组合模型、调整参数并实时预览效果，轻松实现从基础文生图到多步骤高清修复等各类复杂任务。ComfyUI 拥有极佳的兼容性，不仅支持 Windows、macOS 和 Linux 全平台，还广泛适配 NVIDIA、AMD、Intel 及苹果 Silicon 等多种硬件架构，并率先支持 SDXL、Flux、SD3 等前沿模型。\n\n无论是希望深入探索算法潜力的研究人员和开发者，还是追求极致创作自由度的设计师与资深 AI 绘画爱好者，ComfyUI 都能提供强大的支持。其独特的模块化架构允许社区不断扩展新功能，使其成为当前最灵活、生态最丰富的开源扩散模型工具之一，帮助用户将创意高效转化为现实。",109154,"2026-04-18T11:18:24",[14,15,13],{"id":45,"name":46,"github_repo":47,"description_zh":48,"stars":49,"difficulty_score":32,"last_commit_at":50,"category_tags":51,"status":17},6121,"gemini-cli","google-gemini\u002Fgemini-cli","gemini-cli 是一款由谷歌推出的开源 AI 命令行工具，它将强大的 Gemini 大模型能力直接集成到用户的终端环境中。对于习惯在命令行工作的开发者而言，它提供了一条从输入提示词到获取模型响应的最短路径，无需切换窗口即可享受智能辅助。\n\n这款工具主要解决了开发过程中频繁上下文切换的痛点，让用户能在熟悉的终端界面内直接完成代码理解、生成、调试以及自动化运维任务。无论是查询大型代码库、根据草图生成应用，还是执行复杂的 Git 操作，gemini-cli 都能通过自然语言指令高效处理。\n\n它特别适合广大软件工程师、DevOps 人员及技术研究人员使用。其核心亮点包括支持高达 100 万 token 的超长上下文窗口，具备出色的逻辑推理能力；内置 Google 搜索、文件操作及 Shell 命令执行等实用工具；更独特的是，它支持 MCP（模型上下文协议），允许用户灵活扩展自定义集成，连接如图像生成等外部能力。此外，个人谷歌账号即可享受免费的额度支持，且项目基于 Apache 2.0 协议完全开源，是提升终端工作效率的理想助手。",100752,"2026-04-10T01:20:03",[52,13,15,14],"插件",{"id":54,"name":55,"github_repo":56,"description_zh":57,"stars":58,"difficulty_score":32,"last_commit_at":59,"category_tags":60,"status":17},4721,"markitdown","microsoft\u002Fmarkitdown","MarkItDown 是一款由微软 AutoGen 团队打造的轻量级 Python 工具，专为将各类文件高效转换为 Markdown 格式而设计。它支持 PDF、Word、Excel、PPT、图片（含 OCR）、音频（含语音转录）、HTML 乃至 YouTube 链接等多种格式的解析，能够精准提取文档中的标题、列表、表格和链接等关键结构信息。\n\n在人工智能应用日益普及的今天，大语言模型（LLM）虽擅长处理文本，却难以直接读取复杂的二进制办公文档。MarkItDown 恰好解决了这一痛点，它将非结构化或半结构化的文件转化为模型“原生理解”且 Token 效率极高的 Markdown 格式，成为连接本地文件与 AI 分析 pipeline 的理想桥梁。此外，它还提供了 MCP（模型上下文协议）服务器，可无缝集成到 Claude Desktop 等 LLM 应用中。\n\n这款工具特别适合开发者、数据科学家及 AI 研究人员使用，尤其是那些需要构建文档检索增强生成（RAG）系统、进行批量文本分析或希望让 AI 助手直接“阅读”本地文件的用户。虽然生成的内容也具备一定可读性，但其核心优势在于为机器",93400,"2026-04-06T19:52:38",[52,14],{"id":62,"github_repo":63,"name":64,"description_en":65,"description_zh":66,"ai_summary_zh":67,"readme_en":68,"readme_zh":69,"quickstart_zh":70,"use_case_zh":71,"hero_image_url":72,"owner_login":73,"owner_name":74,"owner_avatar_url":75,"owner_bio":76,"owner_company":77,"owner_location":78,"owner_email":79,"owner_twitter":73,"owner_website":80,"owner_url":81,"languages":82,"stars":95,"forks":96,"last_commit_at":97,"license":98,"difficulty_score":10,"env_os":99,"env_gpu":100,"env_ram":101,"env_deps":102,"category_tags":113,"github_topics":114,"view_count":32,"oss_zip_url":79,"oss_zip_packed_at":79,"status":17,"created_at":123,"updated_at":124,"faqs":125,"releases":156},9236,"pkmital\u002FCADL","CADL","ARCHIVED: Contains historical course materials\u002FHomework materials for the FREE MOOC course on \"Creative Applications of Deep Learning w\u002F Tensorflow\" #CADL","CADL 是一套源自 Kadenze 学院免费慕课《基于 TensorFlow 的深度学习创意应用》的开源教学资源库。它并非传统的软件工具，而是包含了三门完整课程的讲座转录、代码实现及作业练习，旨在帮助学习者掌握如何利用深度学习技术进行艺术创作与创意表达。\n\n针对初学者在理解抽象神经网络原理及其在图像、音频、音乐等创意领域应用时的困难，CADL 通过 Jupyter Notebook 形式提供了从零开始的实践路径。内容涵盖 TensorFlow 基础、生成对抗网络（GANs）、变分自编码器（VAE）、Deep Dream 视觉化、风格迁移，以及 Magenta 实验室的音乐与文本建模等前沿技术。用户可以直接运行代码，观察模型如何“幻觉”出图像或创作旋律，从而直观理解算法背后的逻辑。\n\n这套资源特别适合希望跨界融合技术与艺术的开发者、设计师、数字艺术家以及对创意编程感兴趣的研究人员。其独特亮点在于将严谨的计算机科学理论与感性的艺术创作紧密结合，不仅教授如何构建模型，更引导用户探索算法的美学潜力。虽然项目目前处于归档状态，但其系统的课程结构和丰富的实战案例，依然是进入创意深度学习领域的宝贵","CADL 是一套源自 Kadenze 学院免费慕课《基于 TensorFlow 的深度学习创意应用》的开源教学资源库。它并非传统的软件工具，而是包含了三门完整课程的讲座转录、代码实现及作业练习，旨在帮助学习者掌握如何利用深度学习技术进行艺术创作与创意表达。\n\n针对初学者在理解抽象神经网络原理及其在图像、音频、音乐等创意领域应用时的困难，CADL 通过 Jupyter Notebook 形式提供了从零开始的实践路径。内容涵盖 TensorFlow 基础、生成对抗网络（GANs）、变分自编码器（VAE）、Deep Dream 视觉化、风格迁移，以及 Magenta 实验室的音乐与文本建模等前沿技术。用户可以直接运行代码，观察模型如何“幻觉”出图像或创作旋律，从而直观理解算法背后的逻辑。\n\n这套资源特别适合希望跨界融合技术与艺术的开发者、设计师、数字艺术家以及对创意编程感兴趣的研究人员。其独特亮点在于将严谨的计算机科学理论与感性的艺术创作紧密结合，不仅教授如何构建模型，更引导用户探索算法的美学潜力。虽然项目目前处于归档状态，但其系统的课程结构和丰富的实战案例，依然是进入创意深度学习领域的宝贵入门指南。","[![Build Status](https:\u002F\u002Ftravis-ci.org\u002Fpkmital\u002FCADL.svg?branch=master)](https:\u002F\u002Ftravis-ci.org\u002Fpkmital\u002FCADL) [![Slack Channel](https:\u002F\u002Fcadl.herokuapp.com\u002Fbadge.svg)](https:\u002F\u002Fcadl.herokuapp.com)\n\n# \u003Ca href=\"https:\u002F\u002Fwww.kadenze.com\u002Fcourses\u002Fcreative-applications-of-deep-learning-with-tensorflow\u002Finfo\">Creative Applications of Deep Learning w\u002F Tensorflow\u003C\u002Fa>\n\nThis repository contains lecture transcripts and homework assignments as Jupyter Notebooks for the first of three \u003Ca href=\"https:\u002F\u002Fwww.kadenze.com\u002Fpartners\u002Fkadenze-academy\">Kadenze Academy\u003C\u002Fa> courses on \u003Ca href=\"https:\u002F\u002Fwww.kadenze.com\u002Fcourses\u002Fcreative-applications-of-deep-learning-with-tensorflow\u002Finfo\">Creative Applications of Deep Learning w\u002F Tensorflow\u003C\u002Fa>.  It also contains a python package containing all the code developed during all three courses.\n\n**COURSE 1: Creative Applications of Deep Learning with TensorFlow I**  \nSession 1: Introduction to TensorFlow  \nSession 2: Training A Network W\u002F TensorFlow  \nSession 3: Unsupervised And Supervised Learning  \nSession 4: Visualizing And Hallucinating Representations  \nSession 5: Generative Models  \n\n**COURSE 2: Creative Applications of Deep Learning with TensorFlow II**  \nSession 1: Cloud Computing, GPUs, Deploying  \nSession 2: Mixture Density Networks  \nSession 3: Modeling Attention with RNNs, DRAW  \nSession 4: Image-to-Image Translation with GANs  \n\n**COURSE 3: Creative Applications of Deep Learning with TensorFlow III**  \nSession 1: Modeling Music and Art: Google Brain’s Magenta Lab  \nSession 2: Modeling Language: Natural Language Processing  \nSession 3: Autoregressive Image Modeling w\u002F PixelCNN  \nSession 4: Modeling Audio w\u002F Wavenet and NSynth  \n\n# Github Contents Overview\n\n| | Session | Description | Transcript | Homework |\n| --- | --- | --- | --- | --- |\n| Python Package | **[pycadl](https:\u002F\u002Fgithub.com\u002Fpkmital\u002Fpycadl)** | Python package required for courses 2 and 3 | N\u002FA | N\u002FA |\n|Installation| **[Installation](#installation-preliminaries)** | Setting up Python\u002FNotebook and necessary libraries. | N\u002FA | N\u002FA |\n|Preliminaries| **[Preliminaries with Python](session-0)** | Basics of working with Python and images. | N\u002FA | N\u002FA |\n|1| **[Computing with Tensorflow](session-1)** | Working with a small dataset of images.  Dataset preprocessing.  Tensorflow basics.  Sorting\u002Forganizing a dataset. | [lecture-1.ipynb](session-1\u002Flecture-1.ipynb) [Colab](https:\u002F\u002Fcolab.research.google.com\u002Fnotebook#fileId=1bjXwBG0AqGcFbSP5pjjL1A981mBhhN0f) | [session-1.ipynb](session-1\u002Fsession-1.ipynb) |\n|2| **[Basics of Neural Networks](session-2)** | Learn how to create a Neural Network.  Learn to use a neural network to paint an image.  Apply creative thinking to the inputs, outputs, and definition of a network. | [lecture-2.ipynb](session-2\u002Flecture-2.ipynb) | [session-2.ipynb](session-2\u002Fsession-2.ipynb) |\n|3| **[Unsupervised and Supervised Learning](session-3)** | Build an autoencoder.  Extend it with convolution, denoising, and variational layers.  Build a deep classification network.  Apply softmax and onehot encodings to classify audio using a Deep Convolutional Network. | [lecture-3.ipynb](session-3\u002Flecture-3.ipynb) | [session-3.ipynb](session-3\u002Fsession-3.ipynb) |\n|4| **[Visualizing Representations](session-4)** | Visualize backpropped gradients, use them to create Deep Dream, extend Deep Dream w\u002F regularization.  Stylize images or synthesize new images with painterly or hallucinated aesthetics of another image. | [lecture-4.ipynb](session-4\u002Flecture-4.ipynb) | [session-4.ipynb](session-4\u002Fsession-4.ipynb) |\n|5| **[Generative Models](session-5)** | Build a Generative Adversarial Network and extend it with a Variational Autoencoder.  Use the latent space of this network to perform latent arithmetic.  Build a character level Recurrent Neural Network using LSTMs.  Understand different ways of inferring with Recurrent Networks.  | [lecture-5.ipynb](session-5\u002Flecture-5.ipynb) | [session-5-part-1.ipynb](session-5\u002Fsession-5-part-1.ipynb), [session-5-part-2.ipynb](session-5\u002Fsession-5-part-2.ipynb) |\n\n\u003Ca name=\"installation-preliminaries\">\u003C\u002Fa>\n# Installation Preliminaries\n\n\u003C!-- MarkdownTOC autolink=true autoanchor=true bracket=round -->\n\n- [Quickstart Guide](#quickstart-guide)\n    - [Method 1: pip Install](#method-1-pip-install)\n    - [Method 2: Docker Installation](#method-2-docker-installation)\n- [What is Notebook?](#what-is-notebook)\n- [Docker Toolbox](#docker-toolbox)\n- [Jupyter Notebook](#jupyter-notebook)\n    - [OSX\u002FLinux](#osxlinux)\n    - [Windows\u002FDocker Containers](#windowsdocker-containers)\n- [Navigating to Notebook](#navigating-to-notebook)\n- [Installing Python Packages](#installing-python-packages)\n    - [Ubuntu\u002FLinux 64-bit for Python 3.4](#ubuntulinux-64-bit-for-python-34)\n    - [Ubuntu\u002FLinux 64-bit for Python 3.5](#ubuntulinux-64-bit-for-python-35)\n    - [OSX for Python 3.4 or Python 3.5](#osx-for-python-34-or-python-35)\n    - [Other Linux\u002FOSX varieties](#other-linuxosx-varieties)\n- [CUDA\u002FGPU instructions](#cudagpu-instructions)\n- [Testing it](#testing-it)\n- [CUDA\u002FGPU instructions for MacOS](#cudagpu-instructions-for-macos)\n- [Troubleshooting](#troubleshooting)\n    - [ImportError: No module named 'tensorflow'](#importerror-no-module-named-tensorflow)\n    - [AttributeError: module 'tensorflow' has no attribute '\\_\\_version\\_\\_'](#attributeerror-module-tensorflow-has-no-attribute-%5C%5Cversion%5C%5C)\n    - [GPU-related issues](#gpu-related-issues)\n    - [Protobuf library related issues](#protobuf-library-related-issues)\n    - [Cannot import name 'descriptor'](#cannot-import-name-descriptor)\n    - [Can't find setup.py](#cant-find-setuppy)\n    - [SSLError: SSL_VERIFY_FAILED](#sslerror-sslverifyfailed)\n    - [Jupyter Notebook Kernel is always busy \\(Windows\\)](#jupyter-notebook-kernel-is-always-busy-windows)\n    - [Something Else!](#something-else)\n\n\u003C!-- \u002FMarkdownTOC -->\n\nThe first course makes heavy usage of Jupyter Notebook.  This will be necessary for submitting the homeworks and interacting with the guided session notebooks I will provide for each assignment.  Follow along this guide and we'll see how to obtain all of the necessary libraries that we'll be using.  By the end of this, you'll have installed Jupyter Notebook, NumPy, SciPy, and Matplotlib.  While many of these libraries aren't necessary for performing the Deep Learning which we'll get to in later lectures, they are incredibly useful for manipulating data on your computer, preparing data for learning, and exploring results.\n\n\u003Ca name=\"quickstart-guide\">\u003C\u002Fa>\n## Quickstart Guide\n\n**Please skip this section and read the rest of this readme if you are unfamiliar w\u002F Jupyter Notebook or installing Python libraries.  This section is only for advanced users who want to get started quickly.**\n\nThere are two ways to get started.  You can use a native pip installation or use Docker.  There is a quickstart guide for both methods below.  If you have trouble with these, then please skip to the more in depth guides below these sections.\n\n\u003Ca name=\"method-1-pip-install\">\u003C\u002Fa>\n### Method 1: pip Install\n\nFor those of you that are proficient w\u002F Python programming, you'll need Python 3.4+ and the latest TensorFlow which you can install via pip, e.g.:\n\n```bash\n$ pip install tensorflow\n```\n\nor w\u002F CUDA as:\n\n```bash\n$ pip install tensorflow-gpu\n```\n\n\u003Ca name=\"method-2-docker-installation\">\u003C\u002Fa>\n### Method 2: Docker Installation\n\nIf you want a controlled environment w\u002F all dependencies installed for you, and are proficient w\u002F Docker and Jupyter, you can get started w\u002F this repo like so:\n\n```bash\n$ cd\n$ git clone --recursive https:\u002F\u002Fgithub.com\u002Fpkmital\u002FCADL.git\n$ cd CADL\n$ docker build -t cadl .\n$ docker run -it -p 8888:8888 -p 6006:6006 -v \u002F$(pwd)\u002Fsession-1:\u002Fnotebooks --name tf cadl \u002Fbin\u002Fbash\n```\n\nNote that you can skip the build step and download from docker hub instead like so:\n\n```bash\n$ docker run -it -p 8888:8888 -p 6006:6006 -v \u002F$(pwd)\u002Fsession-1:\u002Fnotebooks --name tf pkmital\u002Fcadl \u002Fbin\u002Fbash\n```\n\nBe sure to replace \"session-1\" with whichever session you are working on, e.g. \"session-2\", \"session-3\"...  This will give you a bash prompt with the files for each session:\n\n```bash\nroot@39c4441bcde8:\u002Fnotebooks# ls\nREADME.md  lecture-1.ipynb  libs  session-1.ipynb  tests\n```\n\nWhich you can use to launch jupyter like so:\n\n```bash\nroot@39c4441bcde8:\u002Fnotebooks# jupyter notebook --allow-root\n[I 01:45:27.712 NotebookApp] [nb_conda_kernels] enabled, 2 kernels found\n[I 01:45:27.715 NotebookApp] Writing notebook server cookie secret to \u002Froot\u002F.local\u002Fshare\u002Fjupyter\u002Fruntime\u002Fnotebook_cookie_secret\n[W 01:45:27.729 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.\n[I 01:45:27.799 NotebookApp] [nb_anacondacloud] enabled\n[I 01:45:27.802 NotebookApp] [nb_conda] enabled\n[I 01:45:27.856 NotebookApp] ✓ nbpresent HTML export ENABLED\n[W 01:45:27.856 NotebookApp] ✗ nbpresent PDF export DISABLED: No module named 'nbbrowserpdf'\n[I 01:45:27.858 NotebookApp] Serving notebooks from local directory: \u002Fnotebooks\n[I 01:45:27.858 NotebookApp] 0 active kernels\n[I 01:45:27.858 NotebookApp] The Jupyter Notebook is running at: http:\u002F\u002F[all ip addresses on your system]:8888\u002F?token=dd68eeffd8f227dd789327c981d16b24631866e909bd6469\n[I 01:45:27.858 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).\n```\n\nJupyter should then be running if you navigate Google Chrome (suggested!) to \"http:\u002F\u002Flocalhost:8888\".  If you navigate to the session-1.ipynb file, you will see the homework, or to \"lecture-1.ipynb\", to find the lecture transcripts.  The same goes for every other session.\n\nIf you need to relaunch the docker image again, you can write:\n\n```bash\n$ cd\n$ cd CADL\n$ docker start -i tf\n```\n\nIf you want to use a GPU version, and have a Linux machine, and have an NVIDIA GPU, you can use [nvidia-docker](https:\u002F\u002Fgithub.com\u002FNVIDIA\u002Fnvidia-docker) (this only works for Linux machines! for non-Linux machines that want to use GPU, please follow the expanded directions below, or the quickstart pip installation above):\n\n```bash\n$ wget -P \u002Ftmp https:\u002F\u002Fgithub.com\u002FNVIDIA\u002Fnvidia-docker\u002Freleases\u002Fdownload\u002Fv1.0.0-rc.3\u002Fnvidia-docker_1.0.0.rc.3-1_amd64.deb\n$ sudo dpkg -i \u002Ftmp\u002Fnvidia-docker*.deb && rm \u002Ftmp\u002Fnvidia-docker*.deb\n$ nvidia-docker build -t cadl-gpu -f Dockerfile-gpu .\n$ nvidia-docker run -it -p 8888:8888 -p 6006:6006 -v \u002F$(pwd)\u002Fsession-1:\u002Fnotebooks --name tf cadl-gpu \u002Fbin\u002Fbash \n$ nvidia-docker start -i tf\n```\n\nIf you had any trouble w\u002F this setup then please go through the rest of this document which provides much more in depth details.\n\n\n\u003Ca name=\"what-is-notebook\">\u003C\u002Fa>\n## What is Notebook?\n\nJupyter Notebook, previously called \"iPython Notebook\" prior to version 4.0, is a way of interacting with Python code using a web browser.  It is a very useful instructional tool that we will be using for all of our homework assignments.  Notebooks have the file extensions \"ipynb\" which are abbreviations of \"iPython Notebook\".  Some websites such as [nbviewer.ipython.org](http:\u002F\u002Fnbviewer.ipython.org) or [www.github.com](http:\u002F\u002Fwww.github.com) can view `.ipynb` files directly as rendered HTML.  However, these are not *interactive* versions of the notebook, meaning, they are not running the python kernel which evaluates\u002Finteracts with the code.  So the notebook is just a static version of the code contained inside of it.\n\nIn order to interact with notebook and start coding, you will need to launch Terminal (for Mac and Linux users).  For Windows users, or for anyone having any problems with the Linux\u002FMac instructions, please follow the next section on [Docker Toolbox](#docker-toolbox) very closely!  If you are not a Windows user, please first try skipping over the next section and use the installation instructions in [Jupyter Notebook](#jupyter-notebook) before trying Docker as this solution will be much faster than running Docker.\n\n\u003Ca name=\"docker-toolbox\">\u003C\u002Fa>\n## Docker Toolbox\n\nCurrently, Windows users can only install Tensorflow via [pip using a 64-bit Python 3.5 environment](https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftensorflow\u002Fblob\u002Fmaster\u002Ftensorflow\u002Fg3doc\u002Fget_started\u002Fos_setup.md#pip-installation-on-windows) or using Docker, as outlined below.\n\nThe easiest way to get up an running on any type of system is to use Docker.  Docker is a way of managing a \"virtual\" Linux machine on your computer which will aid the creation a machine capable of running Tensorflow.  First, please download and install the Docker Toolbox:\n\nhttps:\u002F\u002Fwww.docker.com\u002Fproducts\u002Fdocker-toolbox\n\nLinux users can install docker using their favorite package manager.\n\nFor OSX and Windows users, you'll then need to run the \"Docker Quickstart Terminal\" which will launch a Terminal environment running on a virtual Linux machine on your computer. A virtual machine is basically an emulation of another machine. This is important because we'll use this machine to run Linux and install all of the necessary libraries for running Tensorflow.\n\nNote for Windows users, if you have trouble launching the Docker Quickstart Terminal because you have \"Hyper-V\", please instead try using https:\u002F\u002Fdocs.docker.com\u002Fdocker-for-windows\u002F.  Then launch the newly installed \"Docker CLI\" program.\n\nOnce the Terminal is launched, either via Docker CLI or Docker Quickstart Terminal, run the following command (ignoring the `$` sign at the beginning of each line, which just denote that each line is a terminal command that you should type out exactly and then hit ENTER afterwards):\n\n```shell\n$ cd\n$ docker-machine ip\n```\n\nIf you are using Docker Toolbox, you should see your virtual machine's IP address as a result of the last command.  This is the location of your virtual machine.  \u003Cb>NOTE THIS IP ADDRESS\u003C\u002Fb>, as we'll need it in a second.  If you are using \"Docker for Windows\" instead, then you won't need this IP as we'll just use \"localhost\".\n\nThis next command will move to your \"home\" directory.  We'll then \"clone\" the github repo.  This will download everything for the course using \"git\".  If you have trouble w\u002F this step, make sure you have installed [git](https:\u002F\u002Fgit-scm.com\u002Fdownloads).\n\n```shell\n$ cd\n$ git clone --recursive https:\u002F\u002Fgithub.com\u002Fpkmital\u002FCADL.git\n```\n\nWe'll now print out what the full path to that directory is.  PLEASE NOTE DOWN THIS DIRECTORY.  This is where everything will happen, and I'll explain that in a minute.\n\n```shell\n$ echo \u002F$(pwd)\u002FCADL\n```\n\nNow run the following command, which will download everything we need to run tensorflow, python, and jupyter notebook (again, ignore the \"$\" at the beginning of the line only)!\n\n```shell\n$ docker run -it -p 8888:8888 -p 6006:6006 -v \u002F$(pwd)\u002FCADL:\u002Fnotebooks --name tf pkmital\u002Fcadl\n```\n\nWhat this is doing is:\n    * Running the docker image [pkmital\u002Fcadl](https:\u002F\u002Fhub.docker.com\u002Fr\u002Fpkmital\u002Fcadl\u002F)\n    * --name is giving it a shorthand name of \"tf\"\n    * -v is mirroring the directory \"\u002F$(pwd)\u002FCADL\" to the virtual machine's directory of \"\u002Fnotebooks\"\n    * -p is forwarding ports from the virtual machine to your local machine so that you can access the virtual machine's port\n    * -it is running it as an interactive process\n\nYou will want to put files inside the \"\u002Fnotebooks\" directory *only*.  If you place files on the virtual machine outside of the \"\u002Fnotebooks\" directory, which is the SAME as the \"CADL\" directory on your local machine, they will *not* be saved.  We are using Docker to mirror the \"CADL\" directory on a virtual machine which has everything necessary for us to code in Python and Tensorflow.  _Whatever is in that directory will be mirrored on the virtual machine's directory under `\u002Fnotebooks`._\n\nYou can also try running the docker run command with any other directory. For instance:\n\n```shell\n$ docker run -it -p 8888:8888 -p 6006:6006 -v \u002FUsers\u002FYOURUSERNAME\u002FDesktop:\u002Fnotebooks --name tf pkmital\u002Fcadl\n```\n\nWhich would mean that your Desktop is where you can move files around so that on the virtual machine, you can interact with them under the `\u002Fnotebooks`directory.\n\nFor OSX users, if you are installing Docker because you had installation problems using Anaconda and pip, you would instead write the following command (note the missing slash):\n\n```shell\n$ docker run -it -p 8888:8888 -p 6006:6006 -v $(pwd)\u002FCADL:\u002Fnotebooks --name tf pkmital\u002Fcadl\n```\n\nWhen you want to start this machine, you will launch the Docker Quickstart Terminal and then write:\n\n```shell\n$ cd\n$ docker start -i tf\n```\n\nNotice that the command prompt will now be `#` instead of `$`.  You should have a new folder \"tensorflow\" inside your Home directory.  This directory will be empty to begin with.  Please make sure you do everything inside this directory only or else any files you make on your virtual machine WILL BE ERASED once it is shutdown!  When you clone the CADL repository, or expand the zip file downloads contents inside this directory via your Windows machine (it will be in your Home directory under a folder \"cadl\"), then you will be able to access it via your Docker instance.\n\nFor instance, after running the `docker start -i tf` command, try going into the directory `\u002Fnotebooks`:\n\n```shell\n# cd \u002Fnotebooks\n```\n\n\u003Ca name=\"jupyter-notebook\">\u003C\u002Fa>\n## Jupyter Notebook\n\n\u003Ca name=\"osxlinux\">\u003C\u002Fa>\n### OSX\u002FLinux\n\nNote: Windows\u002FDocker users should scroll past this section to [\"Windows\u002FDocker\"](#windows-docker-containers).  For OSX\u002FLinux users, the easiest way to ensure you have Python 3.4 or higher and Jupter Notebook is to install Anaconda for Python 3.5 located here:\n\n[OSX](https:\u002F\u002Fdocs.continuum.io\u002Fanaconda\u002Finstall#anaconda-for-os-x-command-line-install) or [Linux](https:\u002F\u002Fdocs.continuum.io\u002Fanaconda\u002Finstall#linux-install)\n\nMake sure you restart your Terminal after you install Anaconda as there are some PATH variables that have to be set.\n\nThen run the following:\n\n```shell\n$ curl https:\u002F\u002Fbootstrap.pypa.io\u002Fez_setup.py -o - | python\n```\n\nIf you already have conda, but only have Python 2, you can very easily [add a new environment w\u002F Python 3](http:\u002F\u002Fconda.pydata.org\u002Fdocs\u002Fpy2or3.html#create-a-python-3-5-environment) and switch back and forth as needed.  Or if you do not have Anaconda, but have a system based install, I'd really recommend either using Anaconda or [pyenv](https:\u002F\u002Fgithub.com\u002Fyyuu\u002Fpyenv) to help you manage both python installations.\n\nWith Anaconda installed, you will have python and the package \"ipython[notebook]\", along with a ton of other very useful packages such as numpy, matplotlib, scikit-learn, scikit-image, and many others.\n\nWith everything installed, restart your Terminal application (on OSX, you can use Spotlight to find the Terminal application), and then navigate to the directory containing the \"ipynb\", or \"iPython Notebook\" file, by \"cd'ing\" (pronounced, see-dee-ing), into that directory.  This involves typing the command: \"cd some_directory\".  Once inside the directory of the notebook file, you will then type: \"jupyter notebook\".  If this command does not work, it means you do not have notebook installed!  Try installed anaconda as above, restart your Terminal application, or manually install notebook like so (ignore the \"$\" signs which just denote that this is a Terminal command that you should type out exactly and then hit ENTER!):\n\n```shell\n$ pip3 install ipython[notebook]\n$ jupyter notebook\n```\n\nIf you run into issues that say something such as:\n\n```\n[W 20:37:40.543 NotebookApp] Kernel not found: None\n```\n\nThen please try first running:\n\n```shell\n$ ipython3 kernel install\n```\n\n\u003Ca name=\"windows-docker-containers\">\n\u003Ca name=\"windowsdocker-containers\">\u003C\u002Fa>\n### Windows\u002FDocker Containers\n\nFor users running firewalls, you must make sure you have an exception as per [Jupyter Notebooks Firewall Instructions](http:\u002F\u002Fjupyter-notebook.readthedocs.io\u002Fen\u002Flatest\u002Fpublic_server.html#firewall-setup) otherwise you may not be able to interact with the notebook.  Namely, you will need to allow connections from 127.0.0.1 (localhost) on ports from 49152 to 65535.  Once inside your Docker container as outlined above, you can now launch notebook like so:\n\n```shell\n$ cd \u002Fnotebooks\n$ jupyter notebook &\n```\n\nNote on Virtual versus Windows Directories:\n\nThis is tricky to grasp, mostly because I didn't explain it. Docker is \"virtual\" computer running inside your computer. It has its own filesystem and its own directories. So you can't reference your Windows machine's directories inside this machine. When you first ran docker (e.g. `$ docker run -it -p 8888:8888 -p 6006:6006 -v \u002F$(pwd)\u002Ftensorflow:\u002Fnotebooks --name tf pkmital\u002Fcadl`) it included as part of its command: `-v \u002F$(pwd)\u002Ftensorflow:\u002Fnotebooks`. What that was doing is \"mirroring\" a directory on your Windows machine inside your Virtual machine. So whatever was in your Windows machine under the directory `\u002F$(pwd)\u002Ftensorflow` would appear in the Virtual machine under `\u002Fnotebooks`. That Windows directory is likely `\u002FUsers\u002F\u003CYOURUSERNAME>\u002Ftensorflow`. So _ONLY_ inside that directory, create it if it doesn't exist, should you put files in order to access it on the Virtual machine.\n\nSo let's say your Username was \"pkmital\". Then your home directory would be `\u002FUsers\u002Fpkmital`, and you would have mirrored `\u002FUsers\u002Fpkmital\u002Ftensorflow` on your Windows Machine to the Virtual machine under `\u002Fnotebook`. Now let's say I create a directory `\u002FUsers\u002Fpkmital\u002Ftensorflow\u002Fimages` on my Windows Machine, and then put a bunch of png files in there. I will then see them in my Virtual machine under `\u002Fnotebook\u002Fimages`.  If I put the CADL repository inside `\u002FUsers\u002Fpkmital\u002Ftensorflow`, then I should have `\u002FUsers\u002Fpkmital\u002Ftensorflow\u002FCADL\u002Fsession-1\u002Fsession-1.ipynb` and on the Virtual machine, it will be in `\u002Fnotebooks\u002FCADL\u002Fsession-1\u002Fsession-1.ipynb` - From this notebook, running on the virtual machine, accessed with Jupyter Notebook, I would access my images like so:\n\n```python\nimport os\nos.listdir('..\u002F..\u002Fimages')\n```\n\n\u003Ca name=\"navigating-to-notebook\">\u003C\u002Fa>\n## Navigating to Notebook\n\nAfter running \"jupyter notebook &\", you should see a message similar to:\n\n```shell\nroot@182bd64f27d2:~# jupyter notebook &\n[I 21:15:33.647 NotebookApp] Writing notebook server cookie secret to \u002Froot\u002F.local\u002Fshare\u002Fjupyter\u002Fruntime\u002Fnotebook_cookie_secret\n[W 21:15:33.712 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.\n[W 21:15:33.713 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using authentication. This is highly insecure and not recommended.\n[I 21:15:33.720 NotebookApp] Serving notebooks from local directory: \u002Froot\n[I 21:15:33.721 NotebookApp] 0 active kernels\n[I 21:15:33.721 NotebookApp] The IPython Notebook is running at: http:\u002F\u002F[all ip addresses on your system]:8888\u002F\n[I 21:15:33.721 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).\n```\n\nDon't worry if the IP address or command prompt look different.  Note where it says: `The IPython Notebook is running at`.  If you are running Docker (Windows users), this is where we need that IP address.  For OSX\u002FLinux users, we'll use \"localhost\" so don't worry about this.  Now open up Chrome\u002FSafari\u002FFirefox whatever browser you like, and then navigate to:\n\nhttp:\u002F\u002Flocalhost:8888\n\nor for Windows users:\n\nhttp:\u002F\u002FADDRESS:8888\n\nwhere ADDRESS is the ip address you should have noted down before. For instance, on my machine, I would visit the website:\n\nhttp:\u002F\u002F192.168.99.100:8888\n\nThis will launch the Jupyter Notebook where you will be able to interact with the homework assignments!\n\n\u003Ca name=\"installing-python-packages\">\u003C\u002Fa>\n## Installing Python Packages\n\nPackages are libraries or useful extensions to the standard python libraries.  In this course, we'll be using a few including Tensorflow, NumPy, MatPlotLib, SciPy, SciKit-Image, and SciKit-Learn.  Windows users will already have these libraries since the Docker container includes these.  However, if you needed to, you can install these using \"pip\", which is the python package manager.  OSX\u002FLinux users should follow these steps just to be sure they have the latest versions of these packages. In Python 3.4 and higher, `pip` comes with any standard python installation.  In order to use `pip`, first make sure you are using the correct version.  One way to do this is check which pip you are running:\n\n```shell\n$ which pip\n$ which pip3\n```\n\nUse which `pip` points to the install path that makes the most sense (e.g. Anaconda for OSX users for some reason does not symlink pip3 to the python3 pip, and instead points to the system version of python3).\n\nThen you'll write:\n\n```shell\n$ pip3 install -U pip setuptools\n```\n\nTo make sure you have an up to date pip, then:\n\n```shell\n$ pip3 install some_package\n```\n\nTo get the necessary libraries:\n\n```shell\n$ pip3 install \"scikit-image>=0.11.3\" \"numpy>=1.11.0\" \"matplotlib>=1.5.1\" \"scikit-learn>=0.17\"\n```\n\nThis should get you all of the libraries we need for the course, EXCEPT for tensorflow.  Tensorflow is a special case, but can be `pip` installed in much the same way by pointing pip to the github repo corresponding to your OS like so.\n\n\u003Ca name=\"ubuntulinux-64-bit-for-python-34\">\u003C\u002Fa>\n### Ubuntu\u002FLinux 64-bit for Python 3.4\n\n```shell\n$ pip3 install --upgrade https:\u002F\u002Fstorage.googleapis.com\u002Ftensorflow\u002Flinux\u002Fcpu\u002Ftensorflow-0.11.0rc1-cp34-cp34m-linux_x86_64.whl\n```\n\n\u003Ca name=\"ubuntulinux-64-bit-for-python-35\">\u003C\u002Fa>\n### Ubuntu\u002FLinux 64-bit for Python 3.5\n\n```shell\n$ pip3 install --upgrade https:\u002F\u002Fstorage.googleapis.com\u002Ftensorflow\u002Flinux\u002Fcpu\u002Ftensorflow-0.11.0rc1-cp35-cp35m-linux_x86_64.whl\n```\n\n\u003Ca name=\"osx-for-python-34-or-python-35\">\u003C\u002Fa>\n### OSX for Python 3.4 or Python 3.5\n\n```shell\n$ pip3 install --upgrade https:\u002F\u002Fstorage.googleapis.com\u002Ftensorflow\u002Fmac\u002Fcpu\u002Ftensorflow-0.11.0rc1-py3-none-any.whl\n```\n\n\u003Ca name=\"other-linuxosx-varieties\">\u003C\u002Fa>\n### Other Linux\u002FOSX varieties\n\nYou can pip install Tensorflow for most OSX\u002FLinux setups including those that are making use of NVIDIA GPUs and CUDA using one the packages listed on this link:\nhttps:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftensorflow\u002Fblob\u002Fmaster\u002Ftensorflow\u002Fg3doc\u002Fget_started\u002Fos_setup.md#pip-installation\n\nIf you are having trouble with pip installation, try looking here first: [Common Installation Problems](https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftensorflow\u002Fblob\u002F37451589519d15207448dc2d9b1c0309de15d8db\u002Ftensorflow\u002Fg3doc\u002Fget_started\u002Fos_setup.md#common-problems).  Failing that, reach out to us on the forums, or else you may want to instead run a Docker instance as outlined in the Windows instructions above: [Setting up a Docker Container](#docker-toolbox).\n\n\u003Ca name=\"cudagpu-instructions\">\u003C\u002Fa>\n## CUDA\u002FGPU instructions\n\nNote that I have not provided instructions on getting setup w\u002F CUDA as it is beyond the scope of this course!  If you are interested in using GPU acceleration, I highly recommend using Ubuntu Linux and setting up a machine on [Nimbix](https:\u002F\u002Fwww.nimbix.net) or [Amazon EC2](https:\u002F\u002Faws.amazon.com\u002Fec2\u002F\n) using the instructions here: https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftensorflow\u002Fblob\u002Fmaster\u002Ftensorflow\u002Fg3doc\u002Fget_started\u002Fos_setup.md#optional-install-cuda-gpus-on-linux.  If you're using Nimbix, you can skip the install process as there is already a machine pre-installed w\u002F Tensorflow.  Similarly, for Amazon EC2, there are many existing \"images\" of machines that have Tensorflow already installed.\n\n\n\u003Ca name=\"testing-it\">\u003C\u002Fa>\n## Testing it\n\nTo confirm it worked, try running:\n\n```shell\n$ python3 -c 'import tensorflow as tf; print(tf.__version__)'\n```\n\nYou should see 1.0.0 printed, depending on which version you have installed.\n\n\n\u003Ca name=\"cudagpu-instructions-for-macos\">\u003C\u002Fa>\n## CUDA\u002FGPU instructions for MacOS\n\nWhen your Mac is equipped with a NVidia graphics card, you can use the GPU for computing with Tensorflow. GPU enabled computing is not supported for Macs with ATI or Intel graphics cards. \n\nIf you have a previous cpu installation of tensorflow, uninstall it first:\n\n```\n$ pip3 uninstall tensorflow\n```\n\nUsing homebrew, install the following packages:\n\n```\n$ brew install coreutils\n$ brew tap caskroom\u002Fcask\n$ brew cask install cuda\n```\nOnce you have the CUDA Toolkit installed you will need to setup the required environment variables by adding the \nfollowing to your `~\u002F.profile`:\n```\nexport CUDA_HOME=\u002Fusr\u002Flocal\u002Fcuda\nexport DYLD_LIBRARY_PATH=\"$DYLD_LIBRARY_PATH:$CUDA_HOME\u002Flib\"\nexport PATH=\"$CUDA_HOME\u002Fbin:$PATH\"\n```\nTensorflow needs the library libcuda.1.dylib, so we have to create an additional symbolic link:\n```\nsudo ln -sf \u002Fusr\u002Flocal\u002Fcuda\u002Flib\u002Flibcuda.dylib \u002Fusr\u002Flocal\u002Fcuda\u002Flib\u002Flibcuda.1.dylib\n```\nFinally, you will also want to install the **CUDA Deep Neural Network** (cuDNN v5) library which currently requires an \n[_Accelerated Computing Developer Program_](https:\u002F\u002Fdeveloper.nvidia.com\u002Fcudnn) account. Once you have it downloaded \nlocally, you can unzip and move the header and libraries to your local CUDA Toolkit folder:\n```\n$ sudo mv include\u002Fcudnn.h \u002FDeveloper\u002FNVIDIA\u002FCUDA-8.0\u002Finclude\u002F\n$ sudo mv lib\u002Flibcudnn* \u002FDeveloper\u002FNVIDIA\u002FCUDA-8.0\u002Flib\n$ sudo ln -s \u002FDeveloper\u002FNVIDIA\u002FCUDA-8.0\u002Flib\u002Flibcudnn* \u002Fusr\u002Flocal\u002Fcuda\u002Flib\u002F\n```\nThen, finally, install tensorflow with GPU support with:\n```\n$ pip3 install --ignore-installed --upgrade tensorflow-gpu\n```\n\nAccording to the instructions of the TensorFlow website, this should work. However, on MacOS 10.11 (El Capitan) and \nabove, the environment variable `DYLD_LIBRARY_PATH` is ignored, resulting in an error in the interactive python console \nand JetBrains PyCharm IDE. The dynamic library `libcudart.8.0.dylib` fails to load. This\nis due to a new protection meganism in MacOS 10.11 and higher. El Capitan ships with a new OS X feature: System \nIntegrity Protection (SIP), also known as “rootless” mode. This reduces the attack surface for malware that relies on \nmodifying system files by preventing any user, whether with system administrator (“root”) privileges or not from \nmodifying a number of operating system directories and files.\n\n**Warning:** The point of SIP is to prevent malware and other unwanted modifications into system files. Consider whether \nor not you want to dispense with this protection.\nFollow these steps to disable SIP:\n\n* Restart your Mac.\n* Before OS X starts up, hold down Command-R and keep it held down until you see an Apple icon and a progress bar. Release. This boots you into Recovery.\n* From the Utilities menu, select Terminal.\n* At the prompt type exactly the following and then press Return: `csrutil disable`\n* Terminal should display a message that SIP was disabled.\n* From the  menu, select Restart.\n\nYou can re-enable SIP by following the above steps, but using `csrutil enable` instead.\n\n\n\n\u003Ca name=\"troubleshooting\">\u003C\u002Fa>\n## Troubleshooting\n\n\u003Ca name=\"importerror-no-module-named-tensorflow\">\u003C\u002Fa>\n### ImportError: No module named 'tensorflow'\n\nYou may have different versions of Python installed.  You can troubleshoot this by looking at the output of:\n\n```shell\n$ which python3\n$ which pip3\n$ python3 --version\n$ pip3 --version\n$ which python\n$ which pip\n$ python --version\n$ pip --version\n```\n\nYou may simply need to install tensorflow using `pip` instead of `pip3` and\u002For use `python` instead of `python3`, assuming they point to a version of python which is Python 3 or higher.\n\n\u003Ca name=\"attributeerror-module-tensorflow-has-no-attribute-%5C%5Cversion%5C%5C\">\u003C\u002Fa>\n### AttributeError: module 'tensorflow' has no attribute '\\_\\_version\\_\\_'\n\nYou could be running python inside a directory that contains the folder \"tensorflow\".  Try running python inside a different directory.\n\n\n\u003Ca name=\"gpu-related-issues\">\u003C\u002Fa>\n### GPU-related issues\n\nIf you encounter the following when trying to run a TensorFlow program:\n\n```python\nImportError: libcudart.so.7.0: cannot open shared object file: No such file or directory\n```\n\nMake sure you followed the GPU installation [instructions](#optional-install-cuda-gpus-on-linux).\nIf you built from source, and you left the Cuda or cuDNN version empty, try specifying them\nexplicitly.\n\n\u003Ca name=\"protobuf-library-related-issues\">\u003C\u002Fa>\n### Protobuf library related issues\n\nTensorFlow pip package depends on protobuf pip package version\n3.0.0b2. Protobuf's pip package downloaded from [PyPI](https:\u002F\u002Fpypi.python.org)\n(when running `pip install protobuf`) is a Python only library, that has\nPython implementations of proto serialization\u002Fdeserialization which can be 10x-50x\nslower than the C++ implementation. Protobuf also supports a binary extension\nfor the Python package that contains fast C++ based proto parsing. This\nextension is not available in the standard Python only PIP package. We have\ncreated a custom binary pip package for protobuf that contains the binary\nextension. Follow these instructions to install the custom binary protobuf pip\npackage :\n\n```bash\n# Ubuntu\u002FLinux 64-bit:\n$ pip install --upgrade https:\u002F\u002Fstorage.googleapis.com\u002Ftensorflow\u002Flinux\u002Fcpu\u002Fprotobuf-3.0.0b2.post2-cp27-none-linux_x86_64.whl\n\n# Mac OS X:\n$ pip install --upgrade https:\u002F\u002Fstorage.googleapis.com\u002Ftensorflow\u002Fmac\u002Fprotobuf-3.0.0b2.post2-cp27-none-any.whl\n```\n\nand for Python 3 :\n\n```bash\n# Ubuntu\u002FLinux 64-bit:\n$ pip3 install --upgrade https:\u002F\u002Fstorage.googleapis.com\u002Ftensorflow\u002Flinux\u002Fcpu\u002Fprotobuf-3.0.0b2.post2-cp34-none-linux_x86_64.whl\n\n# Mac OS X:\n$ pip3 install --upgrade https:\u002F\u002Fstorage.googleapis.com\u002Ftensorflow\u002Fmac\u002Fprotobuf-3.0.0b2.post2-cp35-none-any.whl\n```\n\nInstall the above package _after_ you have installed TensorFlow via pip, as the\nstandard `pip install tensorflow` would install the python only pip package. The\nabove pip package will over-write the existing protobuf package.\nNote that the binary pip package already has support for protobuf larger than\n64MB, that should fix errors such as these :\n\n```bash\n[libprotobuf ERROR google\u002Fprotobuf\u002Fsrc\u002Fgoogle\u002Fprotobuf\u002Fio\u002Fcoded_stream.cc:207] A\nprotocol message was rejected because it was too big (more than 67108864 bytes).\nTo increase the limit (or to disable these warnings), see\nCodedInputStream::SetTotalBytesLimit() in google\u002Fprotobuf\u002Fio\u002Fcoded_stream.h.\n\n```\n\n\u003Ca name=\"cannot-import-name-descriptor\">\u003C\u002Fa>\n### Cannot import name 'descriptor'\n\n```python\nImportError: Traceback (most recent call last):\n  File \"\u002Fusr\u002Flocal\u002Flib\u002Fpython3.4\u002Fdist-packages\u002Ftensorflow\u002Fcore\u002Fframework\u002Fgraph_pb2.py\", line 6, in \u003Cmodule>\n    from google.protobuf import descriptor as _descriptor\nImportError: cannot import name 'descriptor'\n```\n\nIf you the above error when upgrading to a newer version of TensorFlow, try\nuninstalling both TensorFlow and protobuf (if installed) and re-installing\nTensorFlow (which will also install the correct protobuf dependency).\n\n\u003Ca name=\"cant-find-setuppy\">\u003C\u002Fa>\n### Can't find setup.py\n\nIf, during `pip install`, you encounter an error like:\n\n```bash\n...\nIOError: [Errno 2] No such file or directory: '\u002Ftmp\u002Fpip-o6Tpui-build\u002Fsetup.py'\n```\n\nSolution: upgrade your version of pip:\n\n```bash\npip install --upgrade pip\n```\n\nThis may require `sudo`, depending on how pip is installed.\n\n\u003Ca name=\"sslerror-sslverifyfailed\">\u003C\u002Fa>\n### SSLError: SSL_VERIFY_FAILED\n\nIf, during pip install from a URL, you encounter an error like:\n\n```bash\n...\nSSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed\n```\n\nSolution: Download the wheel manually via curl or wget, and pip install locally.\n\n\u003Ca name=\"jupyter-notebook-kernel-is-always-busy-windows\">\u003C\u002Fa>\n### Jupyter Notebook Kernel is always busy (Windows)\nIf your have installed Docker Toolbox on Windows but your jupyter notebook doesn't run properly (the notebook kernel keeps busy all the time when you open any file) then you might need to try different browsers (One guy tried Edge and it solved his problem after struggling for long time on Chrome\u002FFirefox).\n\nAnd you should also enable port forwarding by:\n\n1. Open VirtualBox\n2. Click on your default docker image.\n3. Click Settings.\n4. Click Network.\n5. Click forward port.\n6. Add a new rule named jupyter with host ip=127.0.0.1 and host\u002Fguess port=8888\n7. Now you should be able to browse your notebook app via localhost:8888 (instead of having to browse 192.168.xx.xx:8888)\n\n\u003Ca name=\"something-else\">\u003C\u002Fa>\n### Something Else!\n\nPost on the [Forums](https:\u002F\u002Fwww.kadenze.com\u002Fcourses\u002Fcreative-applications-of-deep-learning-with-tensorflow-i\u002Fforums?sort=recent_activity) or check on the Tensorflow [README](https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftensorflow\u002Fblob\u002Fmaster\u002Ftensorflow\u002Fg3doc\u002Fget_started\u002Fos_setup.md#pip-installation)\n","[![构建状态](https:\u002F\u002Ftravis-ci.org\u002Fpkmital\u002FCADL.svg?branch=master)](https:\u002F\u002Ftravis-ci.org\u002Fpkmital\u002FCADL) [![Slack 频道](https:\u002F\u002Fcadl.herokuapp.com\u002Fbadge.svg)](https:\u002F\u002Fcadl.herokuapp.com)\n\n# \u003Ca href=\"https:\u002F\u002Fwww.kadenze.com\u002Fcourses\u002Fcreative-applications-of-deep-learning-with-tensorflow\u002Finfo\">使用 TensorFlow 的深度学习创意应用\u003C\u002Fa>\n\n此仓库包含三门 \u003Ca href=\"https:\u002F\u002Fwww.kadenze.com\u002Fpartners\u002Fkadenze-academy\">Kadenze Academy\u003C\u002Fa> 课程中的第一门——\u003Ca href=\"https:\u002F\u002Fwww.kadenze.com\u002Fcourses\u002Fcreative-applications-of-deep-learning-with-tensorflow\u002Finfo\">使用 TensorFlow 的深度学习创意应用\u003C\u002Fa>——的讲座文字稿和作业，以 Jupyter Notebook 形式呈现。此外，还包含一个 Python 软件包，其中包含了在全部三门课程中开发的所有代码。\n\n**课程 1：使用 TensorFlow 的深度学习创意应用 I**  \n第 1 讲：TensorFlow 简介  \n第 2 讲：使用 TensorFlow 训练神经网络  \n第 3 讲：无监督与监督学习  \n第 4 讲：可视化与幻觉式表征  \n第 5 讲：生成模型  \n\n**课程 2：使用 TensorFlow 的深度学习创意应用 II**  \n第 1 讲：云计算、GPU 与部署  \n第 2 讲：混合密度网络  \n第 3 讲：用 RNN 和 DRAW 建模注意力机制  \n第 4 讲：使用 GAN 进行图像到图像的转换  \n\n**课程 3：使用 TensorFlow 的深度学习创意应用 III**  \n第 1 讲：建模音乐与艺术：Google Brain 的 Magenta 实验室  \n第 2 讲：建模语言：自然语言处理  \n第 3 讲：使用 PixelCNN 进行自回归图像建模  \n第 4 讲：使用 WaveNet 和 NSynth 建模音频  \n\n# GitHub 内容概览\n\n| | 讲次 | 描述 | 文字稿 | 作业 |\n| --- | --- | --- | --- | --- |\n| Python 软件包 | **[pycadl](https:\u002F\u002Fgithub.com\u002Fpkmital\u002Fpycadl)** | 课程 2 和 3 所需的 Python 软件包 | 不适用 | 不适用 |\n|安装| **[安装预备知识](#installation-preliminaries)** | 设置 Python\u002FNotebook 及必要库。 | 不适用 | 不适用 |\n|预备知识| **[Python 预备知识](session-0)** | 使用 Python 和图像的基本操作。 | 不适用 | 不适用 |\n|1| **[使用 TensorFlow 进行计算](session-1)** | 处理小型图像数据集。数据预处理。TensorFlow 基础知识。对数据集进行排序和整理。 | [lecture-1.ipynb](session-1\u002Flecture-1.ipynb) [Colab](https:\u002F\u002Fcolab.research.google.com\u002Fnotebook#fileId=1bjXwBG0AqGcFbSP5pjjL1A981mBhhN0f) | [session-1.ipynb](session-1\u002Fsession-1.ipynb) |\n|2| **[神经网络基础](session-2)** | 学习如何创建神经网络。学习使用神经网络绘制图像。将创造性思维应用于网络的输入、输出及定义。 | [lecture-2.ipynb](session-2\u002Flecture-2.ipynb) | [session-2.ipynb](session-2\u002Fsession-2.ipynb) |\n|3| **[无监督与监督学习](session-3)** | 构建自编码器。通过卷积、去噪和变分层扩展它。构建深层分类网络。使用 softmax 和 onehot 编码，利用深度卷积网络对音频进行分类。 | [lecture-3.ipynb](session-3\u002Flecture-3.ipynb) | [session-3.ipynb](session-3\u002Fsession-3.ipynb) |\n|4| **[可视化表征](session-4)** | 可视化反向传播的梯度，利用它们生成 Deep Dream，并通过正则化扩展 Deep Dream。使用另一张图片的绘画风格或幻觉美学来修饰或合成新图片。 | [lecture-4.ipynb](session-4\u002Flecture-4.ipynb) | [session-4.ipynb](session-4\u002Fsession-4.ipynb) |\n|5| **[生成模型](session-5)** | 构建生成对抗网络，并结合变分自编码器进行扩展。利用该网络的潜在空间进行潜在运算。使用 LSTM 构建字符级循环神经网络。理解循环神经网络的不同推断方式。 | [lecture-5.ipynb](session-5\u002Flecture-5.ipynb) | [session-5-part-1.ipynb](session-5\u002Fsession-5-part-1.ipynb), [session-5-part-2.ipynb](session-5\u002Fsession-5-part-2.ipynb) |\n\n\u003Ca name=\"installation-preliminaries\">\u003C\u002Fa>\n# 安装预备知识\n\n\u003C!-- MarkdownTOC autolink=true autoanchor=true bracket=round -->\n\n- [快速入门指南](#quickstart-guide)\n    - [方法 1：pip 安装](#method-1-pip-install)\n    - [方法 2：Docker 安装](#method-2-docker-installation)\n- [什么是 Notebook？](#what-is-notebook)\n- [Docker 工具箱](#docker-toolbox)\n- [Jupyter Notebook](#jupyter-notebook)\n    - [OSX\u002FLinux](#osxlinux)\n    - [Windows\u002FDocker 容器](#windowsdocker-containers)\n- [导航至 Notebook](#navigating-to-notebook)\n- [安装 Python 包](#installing-python-packages)\n    - [适用于 Python 3.4 的 Ubuntu\u002FLinux 64 位](#ubuntulinux-64-bit-for-python-34)\n    - [适用于 Python 3.5 的 Ubuntu\u002FLinux 64 位](#ubuntulinux-64-bit-for-python-35)\n    - [适用于 Python 3.4 或 3.5 的 OSX](#osx-for-python-34-or-python-35)\n    - [其他 Linux\u002FOSX 版本](#other-linuxosx-varieties)\n- [CUDA\u002FGPU 指令](#cudagpu-instructions)\n- [测试](#testing-it)\n- [适用于 macOS 的 CUDA\u002FGPU 指令](#cudagpu-instructions-for-macos)\n- [故障排除](#troubleshooting)\n    - [ImportError: 没有名为 'tensorflow' 的模块](#importerror-no-module-named-tensorflow)\n    - [AttributeError: 模块 'tensorflow' 没有属性 '__version__'](#attributeerror-module-tensorflow-has-no-attribute-%5C%5Cversion%5C%5C)\n    - [GPU 相关问题](#gpu-related-issues)\n    - [Protobuf 库相关问题](#protobuf-library-related-issues)\n    - [无法导入名称 'descriptor'](#cannot-import-name-descriptor)\n    - [找不到 setup.py](#cant-find-setuppy)\n    - [SSLError: SSL_VERIFY_FAILED](#sslerror-sslverifyfailed)\n    - [Jupyter Notebook 内核始终繁忙（Windows）](#jupyter-notebook-kernel-is-always-busy-windows)\n    - [其他问题！](#something-else)\n\n\u003C!-- \u002FMarkdownTOC -->\n\n第一门课程大量使用 Jupyter Notebook。这对于提交作业以及与我为每次作业提供的引导式会话笔记本互动至关重要。请按照本指南操作，我们将了解如何获取所有必要的库。完成本步骤后，您将成功安装 Jupyter Notebook、NumPy、SciPy 和 Matplotlib。尽管这些库在后续讲座中涉及的深度学习任务中并非必需，但它们对于在计算机上处理数据、准备学习数据以及探索结果非常有用。\n\n\u003Ca name=\"quickstart-guide\">\u003C\u002Fa>\n\n## 快速入门指南\n\n**如果您不熟悉 Jupyter Notebook 或 Python 库的安装，请跳过本节，直接阅读本自述文件的其余部分。本节仅适用于希望快速上手的高级用户。**\n\n有两种方法可以开始使用。您可以使用原生的 pip 安装，也可以使用 Docker。下面分别提供了这两种方法的快速入门指南。如果您在使用这些方法时遇到困难，请跳到这些部分下方的更详细指南。\n\n\u003Ca name=\"method-1-pip-install\">\u003C\u002Fa>\n### 方法 1：pip 安装\n\n对于精通 Python 编程的用户，您需要 Python 3.4 或更高版本以及最新版 TensorFlow，可以通过 pip 安装，例如：\n\n```bash\n$ pip install tensorflow\n```\n\n或者带有 CUDA 的版本：\n\n```bash\n$ pip install tensorflow-gpu\n```\n\n\u003Ca name=\"method-2-docker-installation\">\u003C\u002Fa>\n### 方法 2：Docker 安装\n\n如果您希望在一个受控环境中运行，并且所有依赖项都已经为您安装好，同时您也熟悉 Docker 和 Jupyter，那么您可以按照以下步骤开始使用本仓库：\n\n```bash\n$ cd\n$ git clone --recursive https:\u002F\u002Fgithub.com\u002Fpkmital\u002FCADL.git\n$ cd CADL\n$ docker build -t cadl .\n$ docker run -it -p 8888:8888 -p 6006:6006 -v \u002F$(pwd)\u002Fsession-1:\u002Fnotebooks --name tf cadl \u002Fbin\u002Fbash\n```\n\n请注意，您也可以跳过构建步骤，直接从 Docker Hub 下载镜像，如下所示：\n\n```bash\n$ docker run -it -p 8888:8888 -p 6006:6006 -v \u002F$(pwd)\u002Fsession-1:\u002Fnotebooks --name tf pkmital\u002Fcadl \u002Fbin\u002Fbash\n```\n\n请确保将“session-1”替换为您正在使用的会话名称，例如“session-2”、“session-3”等。这将为您提供一个包含每个会话文件的 bash 提示符：\n\n```bash\nroot@39c4441bcde8:\u002Fnotebooks# ls\nREADME.md  lecture-1.ipynb  libs  session-1.ipynb  tests\n```\n\n然后您可以使用以下命令启动 Jupyter：\n\n```bash\nroot@39c4441bcde8:\u002Fnotebooks# jupyter notebook --allow-root\n[I 01:45:27.712 NotebookApp] [nb_conda_kernels] 启用，找到 2 个内核\n[I 01:45:27.715 NotebookApp] 将笔记本服务器的 Cookie 密钥写入 \u002Froot\u002F.local\u002Fshare\u002Fjupyter\u002Fruntime\u002Fnotebook_cookie_secret\n[W 01:45:27.729 NotebookApp] 警告：笔记本服务器监听所有 IP 地址，且未使用加密。这并不推荐。\n[I 01:45:27.799 NotebookApp] [nb_anacondacloud] 已启用\n[I 01:45:27.802 NotebookApp] [nb_conda] 已启用\n[I 01:45:27.856 NotebookApp] ✓ nbpresent HTML 导出已启用\n[W 01:45:27.856 NotebookApp] ✗ nbpresent PDF 导出已禁用：未找到名为 'nbbrowserpdf' 的模块\n[I 01:45:27.858 NotebookApp] 正在为本地目录中的笔记本提供服务：\u002Fnotebooks\n[I 01:45:27.858 NotebookApp] 当前有 0 个活动内核\n[I 01:45:27.858 NotebookApp] Jupyter Notebook 正在运行于：http:\u002F\u002F[您系统上的所有 IP 地址]:8888\u002F?token=dd68eeffd8f227dd789327c981d16b24631866e909bd6469\n[I 01:45:27.858 NotebookApp] 使用 Control-C 可停止此服务器并关闭所有内核（连续两次以跳过确认）。\n```\n\n随后，如果您使用 Google Chrome 浏览器（推荐）访问 “http:\u002F\u002Flocalhost:8888”，Jupyter 应该已经成功运行。如果导航到 session-1.ipynb 文件，您将看到作业；而导航到 “lecture-1.ipynb” 则可以看到课程讲义。其他会话也是如此。\n\n如果您需要再次启动 Docker 镜像，可以执行以下命令：\n\n```bash\n$ cd\n$ cd CADL\n$ docker start -i tf\n```\n\n如果您希望使用 GPU 版本，并且您的机器是 Linux 系统且配备了 NVIDIA GPU，您可以使用 [nvidia-docker](https:\u002F\u002Fgithub.com\u002FNVIDIA\u002Fnvidia-docker)（此方法仅适用于 Linux 系统！对于非 Linux 系统但希望使用 GPU 的用户，请参阅下方的扩展说明或上述的快速 pip 安装方法）：\n\n```bash\n$ wget -P \u002Ftmp https:\u002F\u002Fgithub.com\u002FNVIDIA\u002Fnvidia-docker\u002Freleases\u002Fdownload\u002Fv1.0.0-rc.3\u002Fnvidia-docker_1.0.0.rc.3-1_amd64.deb\n$ sudo dpkg -i \u002Ftmp\u002Fnvidia-docker*.deb && rm \u002Ftmp\u002Fnvidia-docker*.deb\n$ nvidia-docker build -t cadl-gpu -f Dockerfile-gpu .\n$ nvidia-docker run -it -p 8888:8888 -p 6006:6006 -v \u002F$(pwd)\u002Fsession-1:\u002Fnotebooks --name tf cadl-gpu \u002Fbin\u002Fbash \n$ nvidia-docker start -i tf\n```\n\n如果您在设置过程中遇到任何问题，请继续阅读本文档的其余部分，其中提供了更为详细的说明。\n\n\n\u003Ca name=\"what-is-notebook\">\u003C\u002Fa>\n## 什么是 Notebook？\n\nJupyter Notebook，此前在 4.0 版本之前称为 “iPython Notebook”，是一种通过网页浏览器与 Python 代码进行交互的方式。它是一种非常有用的教学工具，我们将用于所有的作业任务。Notebook 文件的扩展名是 “ipynb”，这是 “iPython Notebook” 的缩写。一些网站，如 [nbviewer.ipython.org](http:\u002F\u002Fnbviewer.ipython.org) 或 [www.github.com](http:\u002F\u002Fwww.github.com)，可以直接将 `.ipynb` 文件渲染为 HTML 格式查看。然而，这些并不是可交互的版本，也就是说，它们并没有运行评估和交互代码的 Python 内核。因此，Notebook 只是其中代码的静态版本。\n\n要与 Notebook 交互并开始编写代码，您需要启动终端（适用于 Mac 和 Linux 用户）。对于 Windows 用户，或者任何在使用 Linux\u002FMac 指令时遇到问题的人士，请务必仔细遵循关于 [Docker Toolbox](#docker-toolbox) 的下一节内容！如果您不是 Windows 用户，请先尝试跳过下一节，直接使用 [Jupyter Notebook](#jupyter-notebook) 中的安装说明，然后再尝试 Docker，因为这种方法通常比运行 Docker 更快。\n\n\u003Ca name=\"docker-toolbox\">\u003C\u002Fa>\n\n## Docker 工具箱\n\n目前，Windows 用户只能通过以下两种方式安装 TensorFlow：使用 64 位 Python 3.5 环境并通过 `pip` 安装（详见 [TensorFlow 官方文档](https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftensorflow\u002Fblob\u002Fmaster\u002Ftensorflow\u002Fg3doc\u002Fget_started\u002Fos_setup.md#pip-installation-on-windows)），或者按照下文所述使用 Docker。\n\n在任何类型的系统上快速启动并运行的最简单方法就是使用 Docker。Docker 是一种在你的计算机上管理“虚拟”Linux 系统的方式，它可以帮助你创建一个能够运行 TensorFlow 的环境。首先，请下载并安装 Docker 工具箱：\n\nhttps:\u002F\u002Fwww.docker.com\u002Fproducts\u002Fdocker-toolbox\n\nLinux 用户可以使用自己喜欢的包管理器来安装 Docker。\n\n对于 macOS 和 Windows 用户，接下来你需要运行“Docker Quickstart Terminal”，它会启动一个在你的计算机上的虚拟 Linux 系统中运行的终端环境。虚拟机本质上是另一种机器的模拟。这一点很重要，因为我们将使用这个虚拟机来运行 Linux，并安装所有运行 TensorFlow 所需的库。\n\n请注意，如果你在 Windows 上遇到无法启动 Docker Quickstart Terminal 的问题，可能是因为你已经安装了 Hyper-V。在这种情况下，请尝试使用 [Docker for Windows](https:\u002F\u002Fdocs.docker.com\u002Fdocker-for-windows\u002F)。然后启动新安装的“Docker CLI”程序。\n\n一旦终端启动，无论是通过 Docker CLI 还是 Docker Quickstart Terminal，都请运行以下命令（忽略每行开头的 `$` 符号，它只是表示该行是一个终端命令，你应该原样输入并按回车键）：\n\n```shell\n$ cd\n$ docker-machine ip\n```\n\n如果你使用的是 Docker 工具箱，那么最后一条命令应该会显示你的虚拟机的 IP 地址。这就是你的虚拟机的位置。\u003Cb>请记下这个 IP 地址\u003C\u002Fb>,我们稍后会用到它。如果你使用的是“Docker for Windows”，则不需要这个 IP，因为我们直接使用 “localhost”。\n\n接下来的命令会切换到你的“主目录”。然后我们会“克隆” GitHub 仓库。这将使用 git 下载课程所需的所有内容。如果在此步骤遇到困难，请确保你已安装 [git](https:\u002F\u002Fgit-scm.com\u002Fdownloads)。\n\n```shell\n$ cd\n$ git clone --recursive https:\u002F\u002Fgithub.com\u002Fpkmital\u002FCADL.git\n```\n\n现在我们将打印出该目录的完整路径。请务必记下这个目录。一切操作都将在这个目录中进行，我稍后会详细说明。\n\n```shell\n$ echo \u002F$(pwd)\u002FCADL\n```\n\n接下来运行以下命令，它将下载运行 TensorFlow、Python 和 Jupyter Notebook 所需的一切文件（同样，只需忽略行首的 `$` 符号）！\n\n```shell\n$ docker run -it -p 8888:8888 -p 6006:6006 -v \u002F$(pwd)\u002FCADL:\u002Fnotebooks --name tf pkmital\u002Fcadl\n```\n\n这条命令的作用是：\n    * 运行 Docker 镜像 [pkmital\u002Fcadl](https:\u002F\u002Fhub.docker.com\u002Fr\u002Fpkmital\u002Fcadl\u002F)\n    * `--name` 为容器指定了一个简短名称“tf”\n    * `-v` 将本地目录 `\u002F$(pwd)\u002FCADL` 映射到虚拟机中的 `\u002Fnotebooks` 目录\n    * `-p` 将虚拟机的端口转发到你的本地机器，以便你可以访问虚拟机的端口\n    * `-it` 以交互式模式运行容器\n\n你应当只将文件放置在 `\u002Fnotebooks` 目录中。如果你将文件放在虚拟机中 `\u002Fnotebooks` 目录之外的位置——而这个位置与你本地机器上的 `CADL` 目录是相同的——这些文件将不会被保存。我们使用 Docker 来将 `CADL` 目录镜像到虚拟机中，该虚拟机具备用 Python 和 TensorFlow 编程所需的全部工具。_该目录中的任何内容都会被镜像到虚拟机的 `\u002Fnotebooks` 目录下。_\n\n你也可以尝试使用其他目录来运行 docker run 命令。例如：\n\n```shell\n$ docker run -it -p 8888:8888 -p 6006:6006 -v \u002FUsers\u002FYOURUSERNAME\u002FDesktop:\u002Fnotebooks --name tf pkmital\u002Fcadl\n```\n\n这意味着你的桌面将成为你可以移动文件的地方，在虚拟机中，你可以在 `\u002Fnotebooks` 目录下与这些文件进行交互。\n\n对于 macOS 用户，如果你因为使用 Anaconda 和 pip 安装时出现问题而选择安装 Docker，则应使用以下命令（注意缺少斜杠）：\n\n```shell\n$ docker run -it -p 8888:8888 -p 6006:6006 -v $(pwd)\u002FCADL:\u002Fnotebooks --name tf pkmital\u002Fcadl\n```\n\n当你想要启动这个容器时，只需打开 Docker Quickstart Terminal，然后输入：\n\n```shell\n$ cd\n$ docker start -i tf\n```\n\n你会注意到提示符现在变成了 `#` 而不是 `$`。你应该会在你的主目录中看到一个新的文件夹“tensorflow”。起初这个目录是空的。请务必只在这个目录中进行操作，否则你在虚拟机上创建的任何文件在容器关闭后都会被删除！当你克隆 CADL 仓库，或者通过 Windows 机器将 ZIP 文件的内容解压到这个目录中（它会出现在你的主目录下的“cadl”文件夹中），你就可以通过 Docker 实例访问这些内容。\n\n例如，在运行 `docker start -i tf` 命令后，试着进入 `\u002Fnotebooks` 目录：\n\n```shell\n# cd \u002Fnotebooks\n```\n\n\u003Ca name=\"jupyter-notebook\">\u003C\u002Fa>\n## Jupyter Notebook\n\n\u003Ca name=\"osxlinux\">\u003C\u002Fa>\n\n### OS X\u002FLinux\n\n注意：Windows\u002FDocker 用户请跳过本节，直接查看【Windows\u002FDocker】部分。对于 OS X\u002FLinux 用户，确保安装了 Python 3.4 或更高版本以及 Jupyter Notebook 的最简单方法是安装 Anaconda for Python 3.5，下载地址如下：\n\n[OS X](https:\u002F\u002Fdocs.continuum.io\u002Fanaconda\u002Finstall#anaconda-for-os-x-command-line-install) 或 [Linux](https:\u002F\u002Fdocs.continuum.io\u002Fanaconda\u002Finstall#linux-install)\n\n安装 Anaconda 后，请务必重启终端，因为需要设置一些 PATH 变量。\n\n然后运行以下命令：\n\n```shell\n$ curl https:\u002F\u002Fbootstrap.pypa.io\u002Fez_setup.py -o - | python\n```\n\n如果你已经安装了 conda，但仅使用 Python 2，可以非常方便地 [添加一个包含 Python 3 的新环境](http:\u002F\u002Fconda.pydata.org\u002Fdocs\u002Fpy2or3.html#create-a-python-3-5-environment)，并根据需要在不同环境之间切换。或者，如果你没有安装 Anaconda，而是通过系统自带的方式安装了 Python，我强烈建议你使用 Anaconda 或 [pyenv](https:\u002F\u002Fgithub.com\u002Fyyuu\u002Fpyenv) 来管理多个 Python 版本的安装。\n\n安装 Anaconda 后，你将拥有 Python 和包 `ipython[notebook]`，以及许多其他非常有用的包，例如 numpy、matplotlib、scikit-learn、scikit-image 等等。\n\n所有软件安装完成后，重启你的终端应用程序（在 OS X 上，你可以使用 Spotlight 搜索“终端”），然后通过 `cd` 命令进入包含 `.ipynb` 或 iPython Notebook 文件的目录。这需要输入命令：`cd some_directory`。进入笔记本文件所在的目录后，输入：`jupyter notebook`。如果此命令无法正常运行，则说明你尚未安装 Jupyter Notebook！请尝试按照上述步骤安装 Anaconda，重启终端，或手动安装 Jupyter Notebook，具体操作如下（请忽略 `$` 符号，它仅表示这是一个终端命令，你需要原样输入并按 Enter 键）：\n\n```shell\n$ pip3 install ipython[notebook]\n$ jupyter notebook\n```\n\n如果你遇到类似以下错误信息：\n\n```\n[W 20:37:40.543 NotebookApp] 内核未找到：无\n```\n\n请先尝试运行：\n\n```shell\n$ ipython3 kernel install\n```\n\n\u003Ca name=\"windows-docker-containers\">\n\u003Ca name=\"windowsdocker-containers\">\u003C\u002Fa>\n### Windows\u002FDocker 容器\n\n对于启用了防火墙的用户，必须按照 [Jupyter Notebooks 防火墙设置说明](http:\u002F\u002Fjupyter-notebook.readthedocs.io\u002Fen\u002Flatest\u002Fpublic_server.html#firewall-setup) 添加例外规则，否则可能无法与笔记本交互。具体来说，你需要允许来自 127.0.0.1（localhost）的连接，并开放 49152 到 65535 范围内的端口。一旦进入如上文所述的 Docker 容器，你就可以这样启动 Jupyter Notebook：\n\n```shell\n$ cd \u002Fnotebooks\n$ jupyter notebook &\n```\n\n关于虚拟机与 Windows 目录的区别：\n\n这一点比较难理解，主要是因为我之前没有解释清楚。Docker 是运行在你电脑内部的“虚拟”计算机，它有自己的文件系统和目录结构。因此，你无法直接引用 Windows 机器上的目录。当你首次运行 Docker 容器时（例如：`$ docker run -it -p 8888:8888 -p 6006:6006 -v \u002F$(pwd)\u002Ftensorflow:\u002Fnotebooks --name tf pkmital\u002Fcadl`），其中包含了 `-v \u002F$(pwd)\u002Ftensorflow:\u002Fnotebooks` 参数，它的作用是将 Windows 机器上的某个目录“镜像”到 Docker 容器中。也就是说，Windows 机器上 `\u002F$(pwd)\u002Ftensorflow` 目录下的内容会出现在 Docker 容器的 `\u002Fnotebooks` 目录下。这个 Windows 目录很可能就是 `\u002FUsers\u002F\u003CYOURUSERNAME>\u002Ftensorflow`。因此，只有在这个目录下创建的文件，才能在 Docker 容器中访问到。\n\n假设你的用户名是 “pkmital”，那么你的主目录就是 `\u002FUsers\u002Fpkmital`，你在 Windows 机器上将 `\u002FUsers\u002Fpkmital\u002Ftensorflow` 目录镜像到了 Docker 容器的 `\u002Fnotebooks` 下。现在，如果我在 Windows 机器上创建了一个 `\u002FUsers\u002Fpkmital\u002Ftensorflow\u002Fimages` 目录，并在里面放了一些 PNG 文件，那么在 Docker 容器的 `\u002Fnotebooks\u002Fimages` 目录下也能看到这些文件。如果我把 CADL 仓库放在 `\u002FUsers\u002Fpkmital\u002Ftensorflow` 下，那么在 Windows 机器上对应的路径就是 `\u002FUsers\u002Fpkmital\u002Ftensorflow\u002FCADL\u002Fsession-1\u002Fsession-1.ipynb`，而在 Docker 容器中则是 `\u002Fnotebooks\u002FCADL\u002Fsession-1\u002Fsession-1.ipynb`。从这个运行在 Docker 容器中的笔记本中，通过 Jupyter Notebook 访问这些图片时，代码可以写成：\n\n```python\nimport os\nos.listdir('..\u002F..\u002Fimages')\n```\n\n\u003Ca name=\"navigating-to-notebook\">\u003C\u002Fa>\n## 进入 Jupyter Notebook\n\n运行 `jupyter notebook &` 后，你应该会看到类似以下的信息：\n\n```shell\nroot@182bd64f27d2:~# jupyter notebook &\n[I 21:15:33.647 NotebookApp] 正在将笔记本服务器的 Cookie 密钥写入 \u002Froot\u002F.local\u002Fshare\u002Fjupyter\u002Fruntime\u002Fnotebook_cookie_secret\n[W 21:15:33.712 NotebookApp] 警告：笔记本服务器正在监听所有 IP 地址，且未启用加密。这并不推荐。\n[W 21:15:33.713 NotebookApp] 警告：笔记本服务器正在监听所有 IP 地址，且未启用身份验证。这非常不安全，也不推荐。\n[I 21:15:33.720 NotebookApp] 正在从本地目录 \u002Froot 提供笔记本服务。\n[I 21:15:33.721 NotebookApp] 当前有 0 个活动内核。\n[I 21:15:33.721 NotebookApp] IPython Notebook 正在运行于：http:\u002F\u002F[你系统的所有 IP 地址]:8888\u002F\n[I 21:15:33.721 NotebookApp] 使用 Control-C 可停止此服务器并关闭所有内核（连续两次可跳过确认）。\n```\n\n如果 IP 地址或命令行提示符看起来有所不同，也不必担心。请注意其中写着：“IPython Notebook 正在运行于”。如果你使用的是 Docker（Windows 用户），则需要记录下这个 IP 地址。而对于 OS X\u002FLinux 用户，我们可以直接使用 “localhost”，因此无需为此担心。接下来，打开你喜欢的浏览器（Chrome、Safari 或 Firefox 等），然后访问：\n\nhttp:\u002F\u002Flocalhost:8888\n\n或者对于 Windows 用户：\n\nhttp:\u002F\u002FADDRESS:8888\n\n其中 ADDRESS 就是你之前记录下来的 IP 地址。例如，在我的机器上，我会访问：\n\nhttp:\u002F\u002F192.168.99.100:8888\n\n这将启动 Jupyter Notebook，你就可以开始完成作业了！\n\n\u003Ca name=\"installing-python-packages\">\u003C\u002Fa>\n\n## 安装 Python 包\n\n包是标准 Python 库的扩展或有用的库。在本课程中，我们将使用几个包，包括 TensorFlow、NumPy、Matplotlib、SciPy、SciKit-Image 和 SciKit-Learn。Windows 用户已经拥有这些库，因为 Docker 容器中已包含它们。不过，如果需要，您也可以使用 Python 包管理器 `pip` 来安装这些包。OSX\u002FLinux 用户应按照以下步骤操作，以确保他们拥有这些包的最新版本。在 Python 3.4 及更高版本中，`pip` 随标准 Python 安装一起提供。要使用 `pip`，请先确保您正在使用正确的版本。一种方法是检查您正在运行哪个 `pip`：\n\n```shell\n$ which pip\n$ which pip3\n```\n\n使用指向最合理安装路径的那个 `pip`（例如，出于某种原因，OSX 用户的 Anaconda 并不会将 `pip3` 链接到 Python 3 的 `pip`，而是指向系统的 Python 3 版本）。\n\n然后您将输入：\n\n```shell\n$ pip3 install -U pip setuptools\n```\n\n以确保您拥有最新版本的 `pip`，接着：\n\n```shell\n$ pip3 install some_package\n```\n\n获取必要的库：\n\n```shell\n$ pip3 install \"scikit-image>=0.11.3\" \"numpy>=1.11.0\" \"matplotlib>=1.5.1\" \"scikit-learn>=0.17\"\n```\n\n这应该能为您安装本课程所需的所有库，但不包括 TensorFlow。TensorFlow 是一个特殊情况，但可以通过类似的方式使用 `pip` 进行安装，只需将 `pip` 指向与您的操作系统相对应的 GitHub 仓库即可。\n\n\u003Ca name=\"ubuntulinux-64-bit-for-python-34\">\u003C\u002Fa>\n### Ubuntu\u002FLinux 64 位系统（适用于 Python 3.4）\n\n```shell\n$ pip3 install --upgrade https:\u002F\u002Fstorage.googleapis.com\u002Ftensorflow\u002Flinux\u002Fcpu\u002Ftensorflow-0.11.0rc1-cp34-cp34m-linux_x86_64.whl\n```\n\n\u003Ca name=\"ubuntulinux-64-bit-for-python-35\">\u003C\u002Fa>\n### Ubuntu\u002FLinux 64 位系统（适用于 Python 3.5）\n\n```shell\n$ pip3 install --upgrade https:\u002F\u002Fstorage.googleapis.com\u002Ftensorflow\u002Flinux\u002Fcpu\u002Ftensorflow-0.11.0rc1-cp35-cp35m-linux_x86_64.whl\n```\n\n\u003Ca name=\"osx-for-python-34-or-python-35\">\u003C\u002Fa>\n### OSX 系统（适用于 Python 3.4 或 Python 3.5）\n\n```shell\n$ pip3 install --upgrade https:\u002F\u002Fstorage.googleapis.com\u002Ftensorflow\u002Fmac\u002Fcpu\u002Ftensorflow-0.11.0rc1-py3-none-any.whl\n```\n\n\u003Ca name=\"other-linuxosx-varieties\">\u003C\u002Fa>\n### 其他 Linux\u002FOSX 系统\n\n对于大多数 OSX\u002FLinux 系统，包括那些使用 NVIDIA GPU 和 CUDA 的系统，您都可以通过以下链接中列出的软件包来使用 `pip` 安装 TensorFlow：\nhttps:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftensorflow\u002Fblob\u002Fmaster\u002Ftensorflow\u002Fg3doc\u002Fget_started\u002Fos_setup.md#pip-installation\n\n如果您在使用 `pip` 安装时遇到问题，请先查看此处：[常见安装问题](https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftensorflow\u002Fblob\u002F37451589519d15207448dc2d9b1c0309de15d8db\u002Ftensorflow\u002Fg3doc\u002Fget_started\u002Fos_setup.md#common-problems)。如果仍然无法解决，您可以前往论坛寻求帮助，或者按照上述 Windows 指南中的说明运行 Docker 实例：[设置 Docker 容器](#docker-toolbox)。\n\n\u003Ca name=\"cudagpu-instructions\">\u003C\u002Fa>\n## CUDA\u002FGPU 使用说明\n\n请注意，我没有提供关于如何设置 CUDA 的说明，因为这超出了本课程的范围！如果您有兴趣使用 GPU 加速，我强烈建议您使用 Ubuntu Linux，并按照此处的说明在 [Nimbix](https:\u002F\u002Fwww.nimbix.net) 或 [Amazon EC2](https:\u002F\u002Faws.amazon.com\u002Fec2\u002F) 上设置一台机器：https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftensorflow\u002Fblob\u002Fmaster\u002Ftensorflow\u002Fg3doc\u002Fget_started\u002Fos_setup.md#optional-install-cuda-gpus-on-linux。如果您使用 Nimbix，可以跳过安装过程，因为那里已经有预装了 TensorFlow 的机器。同样，对于 Amazon EC2，也有许多已经预装了 TensorFlow 的“镜像”可供选择。\n\n\n\u003Ca name=\"testing-it\">\u003C\u002Fa>\n## 测试安装\n\n为确认安装成功，请尝试运行以下命令：\n\n```shell\n$ python3 -c 'import tensorflow as tf; print(tf.__version__)'\n```\n\n根据您安装的版本，您应该会看到输出 1.0.0。\n\n\n\u003Ca name=\"cudagpu-instructions-for-macos\">\u003C\u002Fa>\n\n## macOS 上的 CUDA\u002FGPU 指令\n\n当您的 Mac 配备了 NVIDIA 显卡时，您可以使用 GPU 进行 TensorFlow 计算。对于配备 ATI 或 Intel 显卡的 Mac，不支持 GPU 加速计算。\n\n如果您之前已经安装了 CPU 版本的 TensorFlow，请先将其卸载：\n\n```\n$ pip3 uninstall tensorflow\n```\n\n使用 Homebrew 安装以下软件包：\n\n```\n$ brew install coreutils\n$ brew tap caskroom\u002Fcask\n$ brew cask install cuda\n```\n\nCUDA 工具包安装完成后，您需要设置所需的环境变量，将以下内容添加到您的 `~\u002F.profile` 文件中：\n\n```\nexport CUDA_HOME=\u002Fusr\u002Flocal\u002Fcuda\nexport DYLD_LIBRARY_PATH=\"$DYLD_LIBRARY_PATH:$CUDA_HOME\u002Flib\"\nexport PATH=\"$CUDA_HOME\u002Fbin:$PATH\"\n```\n\nTensorFlow 需要 `libcuda.1.dylib` 库，因此我们需要创建一个额外的符号链接：\n\n```\nsudo ln -sf \u002Fusr\u002Flocal\u002Fcuda\u002Flib\u002Flibcuda.dylib \u002Fusr\u002Flocal\u002Fcuda\u002Flib\u002Flibcuda.1.dylib\n```\n\n最后，您还需要安装 **CUDA 深度神经网络**（cuDNN v5）库，这通常需要一个 [_加速计算开发者计划_](https:\u002F\u002Fdeveloper.nvidia.com\u002Fcudnn) 账户。下载并解压后，将头文件和库文件移动到本地的 CUDA 工具包文件夹中：\n\n```\n$ sudo mv include\u002Fcudnn.h \u002FDeveloper\u002FNVIDIA\u002FCUDA-8.0\u002Finclude\u002F\n$ sudo mv lib\u002Flibcudnn* \u002FDeveloper\u002FNVIDIA\u002FCUDA-8.0\u002Flib\n$ sudo ln -s \u002FDeveloper\u002FNVIDIA\u002FCUDA-8.0\u002Flib\u002Flibcudnn* \u002Fusr\u002Flocal\u002Fcuda\u002Flib\u002F\n```\n\n然后，最后一步，使用以下命令安装带有 GPU 支持的 TensorFlow：\n\n```\n$ pip3 install --ignore-installed --upgrade tensorflow-gpu\n```\n\n根据 TensorFlow 官网的说明，上述步骤应该可以正常工作。然而，在 macOS 10.11（El Capitan）及更高版本上，环境变量 `DYLD_LIBRARY_PATH` 会被忽略，导致在交互式 Python 控制台和 JetBrains PyCharm IDE 中出现错误。动态库 `libcudart.8.0.dylib` 无法加载。这是由于 macOS 10.11 及更高版本引入了一种新的保护机制。El Capitan 引入了一个名为“系统完整性保护”（SIP）的功能，也称为“无根模式”。该功能通过阻止任何用户（无论是否具有系统管理员权限）修改多个操作系统目录和文件来减少恶意软件攻击的可能性。\n\n**警告：** SIP 的作用是防止恶意软件和其他未经授权的修改进入系统文件。请考虑是否要暂时禁用此保护机制。\n\n以下是禁用 SIP 的步骤：\n\n* 重启您的 Mac。\n* 在 OS X 启动之前，按住 Command-R 键，并持续按住直到看到 Apple 标志和进度条。松开键，这将引导您进入恢复模式。\n* 从“实用工具”菜单中选择“终端”。\n* 在提示符下输入以下内容并按回车键：`csrutil disable`\n* 终端应显示 SIP 已被禁用的消息。\n* 从  菜单中选择“重新启动”。\n\n您可以通过执行上述步骤，但使用 `csrutil enable` 命令来重新启用 SIP。\n\n\n\n\u003Ca name=\"troubleshooting\">\u003C\u002Fa>\n## 故障排除\n\n\u003Ca name=\"importerror-no-module-named-tensorflow\">\u003C\u002Fa>\n### ImportError: 没有名为 'tensorflow' 的模块\n\n您可能安装了不同版本的 Python。可以通过查看以下命令的输出来排查问题：\n\n```shell\n$ which python3\n$ which pip3\n$ python3 --version\n$ pip3 --version\n$ which python\n$ which pip\n$ python --version\n$ pip --version\n```\n\n您可能只需要使用 `pip` 而不是 `pip3` 来安装 TensorFlow，或者使用 `python` 而不是 `python3`，前提是它们指向的是 Python 3 或更高版本。\n\n\u003Ca name=\"attributeerror-module-tensorflow-has-no-attribute-%5C%5Cversion%5C%5C\">\u003C\u002Fa>\n### AttributeError: 模块 'tensorflow' 没有属性 '__version__'\n\n您可能正在包含名为 “tensorflow” 文件夹的目录中运行 Python。尝试在其他目录中运行 Python。\n\n\n\u003Ca name=\"gpu-related-issues\">\u003C\u002Fa>\n### GPU 相关问题\n\n如果您在运行 TensorFlow 程序时遇到以下错误：\n\n```python\nImportError: libcudart.so.7.0: 无法打开共享对象文件：没有这样的文件或目录\n```\n\n请确保您已按照 GPU 安装 [说明](#optional-install-cuda-gpus-on-linux) 操作。如果您是从源代码编译的，并且未指定 CUDA 或 cuDNN 的版本，请尝试显式指定它们。\n\n\u003Ca name=\"protobuf-library-related-issues\">\u003C\u002Fa>\n### Protobuf 库相关问题\n\nTensorFlow 的 pip 包依赖于 protobuf 的 pip 包版本 3.0.0b2。从 [PyPI](https:\u002F\u002Fpypi.python.org) 下载的 protobuf pip 包（通过运行 `pip install protobuf` 获取）仅包含 Python 实现的协议序列化\u002F反序列化功能，其速度比 C++ 实现慢 10 到 50 倍。Protobuf 还支持一个用于 Python 包的二进制扩展，该扩展提供了基于 C++ 的快速协议解析功能。然而，标准的纯 Python pip 包并不包含此二进制扩展。为此，我们创建了一个自定义的二进制 protobuf pip 包，其中包含了该二进制扩展。请按照以下步骤安装自定义的二进制 protobuf pip 包：\n\n```bash\n# Ubuntu\u002FLinux 64 位：\n$ pip install --upgrade https:\u002F\u002Fstorage.googleapis.com\u002Ftensorflow\u002Flinux\u002Fcpu\u002Fprotobuf-3.0.0b2.post2-cp27-none-linux_x86_64.whl\n\n# Mac OS X：\n$ pip install --upgrade https:\u002F\u002Fstorage.googleapis.com\u002Ftensorflow\u002Fmac\u002Fprotobuf-3.0.0b2.post2-cp27-none-any.whl\n```\n\n对于 Python 3：\n\n```bash\n# Ubuntu\u002FLinux 64 位：\n$ pip3 install --upgrade https:\u002F\u002Fstorage.googleapis.com\u002Ftensorflow\u002Flinux\u002Fcpu\u002Fprotobuf-3.0.0b2.post2-cp34-none-linux_x86_64.whl\n\n# Mac OS X：\n$ pip3 install --upgrade https:\u002F\u002Fstorage.googleapis.com\u002Ftensorflow\u002Fmac\u002Fprotobuf-3.0.0b2.post2-cp35-none-any.whl\n```\n\n请在通过 pip 安装完 TensorFlow 后再安装上述包，因为标准的 `pip install tensorflow` 会安装纯 Python 版本的 protobuf 包。而上述 pip 包将会覆盖现有的 protobuf 包。\n请注意，该二进制 pip 包已经支持大于 64MB 的 protobuf 消息，这可以解决类似以下的错误：\n\n```bash\n[libprotobuf ERROR google\u002Fprotobuf\u002Fsrc\u002Fgoogle\u002Fprotobuf\u002Fio\u002Fcoded_stream.cc:207] 一个协议消息因过大（超过 67,108,864 字节）而被拒绝。若要增加限制（或关闭这些警告），请参阅 google\u002Fprotobuf\u002Fio\u002Fcoded_stream.h 中的 CodedInputStream::SetTotalBytesLimit() 方法。\n\n```\n\n\u003Ca name=\"cannot-import-name-descriptor\">\u003C\u002Fa>\n### 无法导入名称 'descriptor'\n\n```python\nImportError: 跟踪记录（最近一次调用）:\n  File \"\u002Fusr\u002Flocal\u002Flib\u002Fpython3.4\u002Fdist-packages\u002Ftensorflow\u002Fcore\u002Fframework\u002Fgraph_pb2.py\", 第 6 行，在 \u003Cmodule> 中:\n    from google.protobuf import descriptor as _descriptor\nImportError: 无法导入名称 'descriptor'\n```\n\n如果您在升级到较新版本的 TensorFlow 时遇到上述错误，请尝试卸载 TensorFlow 和 protobuf（如果已安装），然后重新安装 TensorFlow（这也将安装正确的 protobuf 依赖项）。\n\n\u003Ca name=\"cant-find-setuppy\">\u003C\u002Fa>\n\n### 找不到 setup.py\n\n如果在运行 `pip install` 时遇到类似以下的错误：\n\n```bash\n...\nIOError: [Errno 2] 没有这样的文件或目录：'\u002Ftmp\u002Fpip-o6Tpui-build\u002Fsetup.py'\n```\n\n解决方法：升级 pip 的版本：\n\n```bash\npip install --upgrade pip\n```\n\n根据 pip 的安装方式，可能需要使用 `sudo`。\n\n\u003Ca name=\"sslerror-sslverifyfailed\">\u003C\u002Fa>\n### SSLError: SSL_VERIFY_FAILED\n\n如果在通过 URL 使用 pip 安装时遇到类似以下的错误：\n\n```bash\n...\nSSLError: [SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败\n```\n\n解决方法：使用 curl 或 wget 手动下载 wheel 文件，然后在本地使用 pip 进行安装。\n\n\u003Ca name=\"jupyter-notebook-kernel-is-always-busy-windows\">\u003C\u002Fa>\n### Jupyter Notebook 内核始终处于忙碌状态（Windows）\n如果你在 Windows 上安装了 Docker Toolbox，但 Jupyter Notebook 无法正常运行（打开任何文件时内核都一直处于忙碌状态），可以尝试更换浏览器。有人使用 Edge 浏览器后解决了问题，而之前在 Chrome 和 Firefox 上一直无法正常工作。\n\n此外，你还需要启用端口转发，具体步骤如下：\n\n1. 打开 VirtualBox。\n2. 点击你的默认 Docker 镜像。\n3. 点击“设置”。\n4. 选择“网络”。\n5. 点击“端口转发”。\n6. 添加一条名为 jupyter 的新规则，主机 IP 设置为 127.0.0.1，主机端口\u002F目标端口设置为 8888。\n7. 现在你应该能够通过 localhost:8888 访问你的 Jupyter Notebook 应用程序，而无需再使用 192.168.xx.xx:8888。\n\n\u003Ca name=\"something-else\">\u003C\u002Fa>\n### 其他问题！\n\n请在 [论坛](https:\u002F\u002Fwww.kadenze.com\u002Fcourses\u002Fcreative-applications-of-deep-learning-with-tensorflow-i\u002Fforums?sort=recent_activity) 上发帖，或查看 TensorFlow 的 [README](https:\u002F\u002Fgithub.com\u002Ftensorflow\u002Ftensorflow\u002Fblob\u002Fmaster\u002Ftensorflow\u002Fg3doc\u002Fget_started\u002Fos_setup.md#pip-installation)。","# CADL 快速上手指南\n\nCADL (Creative Applications of Deep Learning) 是一个基于 TensorFlow 的深度学习创意应用开源项目，包含完整的课程讲义、Jupyter Notebook 作业示例以及配套的 Python 工具包 (`pycadl`)。本指南将帮助你快速搭建环境并运行第一个示例。\n\n## 环境准备\n\n在开始之前，请确保你的系统满足以下要求：\n\n*   **操作系统**: Linux (推荐 Ubuntu), macOS, 或 Windows (需使用 Docker)。\n*   **Python 版本**: Python 3.4 或更高版本 (推荐 3.5+)。\n*   **核心依赖**:\n    *   TensorFlow (CPU 或 GPU 版本)\n    *   Jupyter Notebook\n    *   NumPy, SciPy, Matplotlib\n*   **硬件加速 (可选)**: 如需使用 GPU 加速，需安装 NVIDIA 显卡及对应的 CUDA  toolkit 和 cuDNN。\n*   **网络建议**: 由于部分依赖包托管于国外源，国内用户建议在安装时使用国内镜像加速（如清华源、阿里源）。\n\n## 安装步骤\n\n你可以选择 **pip 直接安装**（适合熟悉 Python 环境的用户）或 **Docker 安装**（适合希望环境隔离、一键部署的用户）。\n\n### 方法一：pip 安装 (推荐高级用户)\n\n1.  **克隆项目代码**:\n    ```bash\n    git clone --recursive https:\u002F\u002Fgithub.com\u002Fpkmital\u002FCADL.git\n    cd CADL\n    ```\n\n2.  **安装 TensorFlow**:\n    *   **CPU 版本**:\n        ```bash\n        pip install tensorflow\n        ```\n    *   **GPU 版本** (需预先配置好 CUDA 环境):\n        ```bash\n        pip install tensorflow-gpu\n        ```\n    *   *国内加速提示*: 若下载缓慢，可使用清华源：\n        ```bash\n        pip install tensorflow -i https:\u002F\u002Fpypi.tuna.tsinghua.edu.cn\u002Fsimple\n        ```\n\n3.  **安装其他依赖库**:\n    进入项目目录，安装课程所需的辅助库：\n    ```bash\n    pip install jupyter numpy scipy matplotlib\n    ```\n    *(注：如果需要安装项目自带的 `pycadl` 包，请进入对应子目录运行 `python setup.py install`)*\n\n### 方法二：Docker 安装 (推荐新手或 Windows 用户)\n\n此方法会自动配置所有依赖，避免环境冲突。\n\n1.  **克隆项目**:\n    ```bash\n    git clone --recursive https:\u002F\u002Fgithub.com\u002Fpkmital\u002FCADL.git\n    cd CADL\n    ```\n\n2.  **构建并运行容器**:\n    以下命令将构建镜像并启动 Jupyter 服务，映射端口以便浏览器访问。\n    \n    *普通 CPU 版本*:\n    ```bash\n    docker build -t cadl .\n    docker run -it -p 8888:8888 -p 6006:6006 -v $(pwd)\u002Fsession-1:\u002Fnotebooks --name tf cadl \u002Fbin\u002Fbash\n    ```\n    *(Windows PowerShell 用户请将 `$(pwd)` 替换为 `${PWD}`)*\n\n    *或者直接拉取已构建好的镜像*:\n    ```bash\n    docker run -it -p 8888:8888 -p 6006:6006 -v $(pwd)\u002Fsession-1:\u002Fnotebooks --name tf pkmital\u002Fcadl \u002Fbin\u002Fbash\n    ```\n\n3.  **启动 Jupyter**:\n    在容器内的 bash 提示符下输入：\n    ```bash\n    jupyter notebook --allow-root\n    ```\n    终端会输出一个带有 token 的 URL (例如 `http:\u002F\u002F...?token=...`)。\n\n## 基本使用\n\n安装完成后，你可以通过浏览器访问交互式笔记本进行学习和实验。\n\n1.  **访问界面**:\n    打开 Chrome 或 Firefox 浏览器，访问 `http:\u002F\u002Flocalhost:8888`。如果使用的是 Docker，请输入终端中生成的完整 URL（包含 token）。\n\n2.  **运行课程示例**:\n    *   在文件列表中，找到 `session-1` 文件夹。\n    *   点击 `lecture-1.ipynb` 查看第一节课的讲义代码。\n    *   点击 `session-1.ipynb` 开始做作业练习。\n\n3.  **执行代码**:\n    *   点击任意代码单元格 (Cell)。\n    *   按下 `Shift + Enter` 运行当前单元格并跳转到下一个。\n    *   观察图像生成、模型训练等输出结果。\n\n4.  **切换课程章节**:\n    修改 Docker 启动命令中的 `-v` 参数路径，即可加载不同章节的内容。例如加载第二节课：\n    ```bash\n    # 停止并移除旧容器 (如果是 Docker 方式)\n    docker stop tf && docker rm tf\n    \n    # 重新启动映射 session-2\n    docker run -it -p 8888:8888 -p 6006:6006 -v $(pwd)\u002Fsession-2:\u002Fnotebooks --name tf pkmital\u002Fcadl \u002Fbin\u002Fbash\n    ```\n    然后在容器内再次运行 `jupyter notebook --allow-root`。","一位数字艺术家希望利用深度学习技术创作具有独特风格的生成艺术，但缺乏系统的 TensorFlow 实战经验和完整的代码框架。\n\n### 没有 CADL 时\n- 开发者需要在海量零散的技术博客中摸索，难以构建从数据预处理到模型训练的系统性知识体系。\n- 尝试复现 Deep Dream 或 GAN（生成对抗网络）等创意算法时，常因缺少关键的可视化调试代码而陷入黑盒困境，无法理解神经网络内部的表征。\n- 面对复杂的数学公式和抽象概念，缺乏配套的 Jupyter Notebook 交互式练习，导致理论难以转化为实际的创意代码。\n- 想要实现音乐生成或风格迁移等跨模态应用时，需从头编写底层架构，耗费数周时间却难以跑通第一个 Demo。\n\n### 使用 CADL 后\n- 艺术家可以直接跟随三门课程的完整讲义，按部就班地掌握从 TensorFlow 基础到高级生成模型的全链路开发流程。\n- 利用课程提供的现成 Notebooks，立即运行并修改 Deep Dream 和风格迁移代码，通过可视化梯度直观调整艺术效果，大幅降低试错成本。\n- 通过课后作业中的交互式编程任务，将无监督学习、变分自编码器（VAE）等复杂理论直接应用于图像分类和音频合成实践中。\n- 调用封装好的 `pycadl` Python 包，快速搭建 Magenta 音乐模型或 PixelCNN 图像生成器，在几天内即可原型化自己的创意应用。\n\nCADL 将深奥的深度学习理论转化为可执行的创意工具，让创作者能专注于艺术表达而非底层代码的重复造轮子。","https:\u002F\u002Foss.gittoolsai.com\u002Fimages\u002Fpkmital_CADL_01f076a9.png","pkmital","Parag K Mital","https:\u002F\u002Foss.gittoolsai.com\u002Favatars\u002Fpkmital_1a2f37ed.png","Artist and researcher with 20+ years experience in AI and computational arts","@the-garden-in-the-machine ","Los Angeles, CA",null,"https:\u002F\u002Fpkmital.com","https:\u002F\u002Fgithub.com\u002Fpkmital",[83,87,91],{"name":84,"color":85,"percentage":86},"Jupyter Notebook","#DA5B0B",98.8,{"name":88,"color":89,"percentage":90},"Python","#3572A5",1.2,{"name":92,"color":93,"percentage":94},"Shell","#89e051",0,1483,722,"2026-04-10T06:15:10","Apache-2.0","Linux, macOS, Windows","可选。如需使用 GPU，需要 NVIDIA 显卡并安装 CUDA（具体版本未说明，文中提及需安装 nvidia-docker 或 tensorflow-gpu）。MacOS 下的 GPU 支持有单独说明但细节未展开。","未说明",{"notes":103,"python":104,"dependencies":105},"该项目是 Kadenze Academy 深度学习课程的配套代码，主要基于 TensorFlow 1.x 版本（根据仓库年代推断）。提供两种安装方式：pip 原生安装或 Docker 容器化部署。Windows 用户强烈建议使用 Docker Toolbox。课程作业需在 Jupyter Notebook 中运行。若使用 GPU，Linux 用户可使用 nvidia-docker，其他平台需参考详细安装指南配置 CUDA 环境。","3.4+",[106,107,108,109,110,111,112],"tensorflow","tensorflow-gpu","jupyter","numpy","scipy","matplotlib","pycadl",[14],[115,116,106,117,118,119,120,121,122],"jupyter-notebook","neural-network","deep-learning","mooc","dockerfile","machine-learning","tutorial","workshop","2026-03-27T02:49:30.150509","2026-04-19T03:06:37.162755",[126,131,136,141,146,151],{"id":127,"question_zh":128,"answer_zh":129,"source_url":130},41448,"在 Session 4 Part 5 中，使用 Python 3 运行代码时出现关于 dropout 张量形状包含 None 值的错误，如何解决？","这是因为 `get_shape().as_list()` 返回的形状中包含 `None`（通常代表 batch size），直接传给 `np.ones` 会报错。解决方案是将 feed_dict 中的 dropout 参数替换为具体的数值列表。例如，将原本动态获取形状的代码改为：`'net\u002Fdropout\u002Frandom_uniform:0': [[1]*4096]`，或者在生成 ones 数组前处理 None 值，将其替换为 1（即 `[1 if x is None else x for x in shape_list]`）。","https:\u002F\u002Fgithub.com\u002Fpkmital\u002FCADL\u002Fissues\u002F59",{"id":132,"question_zh":133,"answer_zh":134,"source_url":135},41449,"在计算总变分损失（total_variation_loss）的函数中，宽度和高度的索引是否写错了？","是的，这是一个常见的抄写错误。原代码中高度 `h` 和宽度 `w` 都错误地引用了同一个索引 `[1]`。正确的写法应该是分别引用索引 `[1]` 和 `[2]`，即：`h, w = x.get_shape().as_list()[1], x.get_shape().as_list()[2]`。这在使用非正方形图像进行测试时尤为重要。","https:\u002F\u002Fgithub.com\u002Fpkmital\u002FCADL\u002Fissues\u002F92",{"id":137,"question_zh":138,"answer_zh":139,"source_url":140},41450,"运行 VAE 测试时提示找不到 CelebA 数据集（\"Could not find celeb dataset\"），该怎么办？","该错误是因为本地缺少 CelebA 数据集。你需要先手动下载数据集。根据错误提示，应访问 CelebA 项目页面下载 \"Aligned and Cropped\" 版本（文件名通常为 `img_align_celeba.zip`，大小约 1.34 GB），并将其解压到代码期望的路径下（通常是 `.\u002Fimg_align_celeba\u002F` 目录）。如果官方链接失效，请在网络上搜索其他可用的镜像源下载该数据集。","https:\u002F\u002Fgithub.com\u002Fpkmital\u002FCADL\u002Fissues\u002F80",{"id":142,"question_zh":143,"answer_zh":144,"source_url":145},41451,"如何在 Python 2.7 环境下运行原本为 Python 3 编写的课程代码？","需要对代码进行少量修改以兼容 Python 2.7。主要改动包括：1. 将 `from urllib import request` 改为 `import urllib`；2. 将 `urllib.request.urlretrieve(...)` 改为 `urllib.urlretrieve(...)`；3. 移除 `print` 函数中的 `end=..` 参数，直接使用 `print(url)`。注意维护者可能不再主动支持 Python 2.7，建议尽量使用 Python 3。","https:\u002F\u002Fgithub.com\u002Fpkmital\u002FCADL\u002Fissues\u002F4",{"id":147,"question_zh":148,"answer_zh":149,"source_url":150},41452,"在 Windows 上使用 TensorFlow 1.0+ 时，高斯分布（Gaussian\u002FNormal）公式报错或数据类型转换失败，有什么替代方案？","这是由于 TensorFlow API 变更导致的。建议使用 TensorFlow 贡献库中的新分布类来替代旧的手动公式，具体可以使用 `tf.contrib.distributions.Normal`。此外，也可以考察 `tf.nn.moments` 和 `tf.nn.batch_normalization` 来实现类似功能，这些方法在后续教程中对于理解底层原理和加速图形构建也很有帮助。","https:\u002F\u002Fgithub.com\u002Fpkmital\u002FCADL\u002Fissues\u002F66",{"id":152,"question_zh":153,"answer_zh":154,"source_url":155},41453,"在处理大量图片（如 53400 张）进行网格重组时遇到索引越界错误（IndexError），原因是什么？","索引越界通常是因为尝试访问的索引超出了实际数据列表的范围。在这个案例中，用户误以为数据量很大导致算法问题，但实际上是输入数据的形状（shape）定义有误（例如 `zs` 的形状被错误地定义为 `(53400, 2)` 而不是预期的特征维度）。解决方法是检查并修正输入数据的形状定义，确保循环中的索引 `i` 不超过 `examples` 列表的实际长度。虽然算法可以处理大量图片，但需要正确设置 `n_images` 参数并确保数据预处理无误。","https:\u002F\u002Fgithub.com\u002Fpkmital\u002FCADL\u002Fissues\u002F42",[]]