You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

ref_dynamic-graph.ipynb 2.8 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "markdown",
  5. "metadata": {},
  6. "source": [
  7. "# 动态图和静态图\n",
  8. "目前神经网络框架分为[静态图框架和动态图框架](https://blog.csdn.net/qq_36653505/article/details/87875279),PyTorch 和 TensorFlow、Caffe 等框架最大的区别就是他们拥有不同的计算图表现形式。 TensorFlow 使用静态图,这意味着我们先定义计算图,然后不断使用它,而在 PyTorch 中,每次都会重新构建一个新的计算图。通过这次课程,我们会了解静态图和动态图之间的优缺点。\n",
  9. "\n",
  10. "对于使用者来说,两种形式的计算图有着非常大的区别,同时静态图和动态图都有他们各自的优点,比如动态图比较方便debug,使用者能够用任何他们喜欢的方式进行debug,同时非常直观,而静态图是通过先定义后运行的方式,之后再次运行的时候就不再需要重新构建计算图,所以速度会比动态图更快。"
  11. ]
  12. },
  13. {
  14. "cell_type": "markdown",
  15. "metadata": {},
  16. "source": [
  17. "![](https://ws3.sinaimg.cn/large/006tNc79ly1fmai482qumg30rs0fmq6e.gif)"
  18. ]
  19. },
  20. {
  21. "cell_type": "markdown",
  22. "metadata": {},
  23. "source": [
  24. "## PyTorch"
  25. ]
  26. },
  27. {
  28. "cell_type": "code",
  29. "execution_count": 1,
  30. "metadata": {},
  31. "outputs": [],
  32. "source": [
  33. "# pytorch\n",
  34. "import torch\n",
  35. "first_counter = torch.Tensor([0])\n",
  36. "second_counter = torch.Tensor([10])"
  37. ]
  38. },
  39. {
  40. "cell_type": "code",
  41. "execution_count": 2,
  42. "metadata": {},
  43. "outputs": [],
  44. "source": [
  45. "while (first_counter < second_counter):\n",
  46. " first_counter += 2\n",
  47. " second_counter += 1"
  48. ]
  49. },
  50. {
  51. "cell_type": "code",
  52. "execution_count": 3,
  53. "metadata": {},
  54. "outputs": [
  55. {
  56. "name": "stdout",
  57. "output_type": "stream",
  58. "text": [
  59. "tensor([20.])\n",
  60. "tensor([20.])\n"
  61. ]
  62. }
  63. ],
  64. "source": [
  65. "print(first_counter)\n",
  66. "print(second_counter)"
  67. ]
  68. },
  69. {
  70. "cell_type": "markdown",
  71. "metadata": {},
  72. "source": [
  73. "可以看到 PyTorch 的写法跟 Python 的写法是完全一致的,没有任何额外的学习成本\n",
  74. "\n",
  75. "上面的例子展示如何使用静态图和动态图构建 while 循环,看起来动态图的方式更加简单且直观,你觉得呢?"
  76. ]
  77. }
  78. ],
  79. "metadata": {
  80. "kernelspec": {
  81. "display_name": "Python 3",
  82. "language": "python",
  83. "name": "python3"
  84. },
  85. "language_info": {
  86. "codemirror_mode": {
  87. "name": "ipython",
  88. "version": 3
  89. },
  90. "file_extension": ".py",
  91. "mimetype": "text/x-python",
  92. "name": "python",
  93. "nbconvert_exporter": "python",
  94. "pygments_lexer": "ipython3",
  95. "version": "3.7.9"
  96. }
  97. },
  98. "nbformat": 4,
  99. "nbformat_minor": 2
  100. }

机器学习越来越多应用到飞行器、机器人等领域,其目的是利用计算机实现类似人类的智能,从而实现装备的智能化与无人化。本课程旨在引导学生掌握机器学习的基本知识、典型方法与技术,通过具体的应用案例激发学生对该学科的兴趣,鼓励学生能够从人工智能的角度来分析、解决飞行器、机器人所面临的问题和挑战。本课程主要内容包括Python编程基础,机器学习模型,无监督学习、监督学习、深度学习基础知识与实现,并学习如何利用机器学习解决实际问题,从而全面提升自我的《综合能力》。