TensorFlow中的神经网络实现

17 Mar 2025 | 阅读 2 分钟

神经网络是机器学习的一种基本类型。它遵循数据预处理、模型构建和模型评估的人工智能工作流程。

我们将开始学习Python中的面向对象编程和super关键字。

现在让我们通过Anaconda Navigator在我们的系统中启动Jupyter Notebook。

首先,我们必须打开Anaconda Navigator,然后从那里启动Jupyter Notebook

Implementation of Neural Network in TensorFlow

之后,一个命令将在我们的系统中自动运行,如下所示。

Implementation of Neural Network in TensorFlow

然后,将打开以下页面,我们必须在那里编写代码。

Implementation of Neural Network in TensorFlow

然后单击文件并启动编辑器。

Implementation of Neural Network in TensorFlow

现在,它将在我们的系统中成功打开。

然后我们必须在下面的编码部分中理解简单的函数

Implementation of Neural Network in TensorFlow Implementation of Neural Network in TensorFlow Implementation of Neural Network in TensorFlow

运算符

以下是运算符的基本概念

  • 操作类
    • 输入节点
    • 输出节点
    • 全局默认图变量
    • 计算
      • 被扩展类覆盖
Implementation of Neural Network in TensorFlow Implementation of Neural Network in TensorFlow

Graph

图是一个全局变量。我们使用术语“图”是因为TensorFlow运行在图上,我们将在下一节学习TensorFlow基础知识时重申这一点。我们可以将图想象成节点列表。在这种情况下,我们有一个简单的图,其中有两个常量,也就是两个节点n1和n2,它们分别是常量1和2,然后它被输入到某个操作中。因此,在我们的例子中,我们有这种选择操作类,然后这个操作类将被其他类继承。

所以,例如,我们可以添加一个继承操作类的类,在这种情况下,它输入这两个输入1和2,然后输出3,因为1+2=3。我们有一个乘法运算,所以乘法运算说1乘以2,所以输出是2。下面是图。

Implementation of Neural Network in TensorFlow

占位符- 一个“空”节点,需要提供一个值来计算输出。

变量- 它是图的一个可变参数。

图- 连接变量和占位符以进行操作的全局变量。

Implementation of Neural Network in TensorFlow Implementation of Neural Network in TensorFlow

会话: 我们需要在会议中执行所有操作。我们将确保我们应该按照正确的顺序实现节点。

Implementation of Neural Network in TensorFlow Implementation of Neural Network in TensorFlow Implementation of Neural Network in TensorFlow Implementation of Neural Network in TensorFlow Implementation of Neural Network in TensorFlow

在这里,我们完成了我们的运算符和图部分。