Skip to content
This repository has been archived by the owner on Sep 5, 2021. It is now read-only.

Latest commit

 

History

History
59 lines (38 loc) · 1.15 KB

13-Day6.md

File metadata and controls

59 lines (38 loc) · 1.15 KB

第六次课程小结

王政和
2017012269
航天航空学院

1.类

  • 属性、方法、构造函数

2.类的继承

  • 基类、派生类
  • super()方法:子类对象调用父类已被覆盖的方法
  • call()方法:实例名()将调用call()方法

3.模块、层和模型

  • 层的设计:

    class Dense(tf.Module):
    	def __init__(self, in_features, out_features, name=none):
    		super().__init__(name=name)
    		self.w = tf.Variable(
    		 tf.random.normal([in_features, out_features]), name='w')
    		self.b = tf.Variable(tf.zeros([out_features]), name='b')
    	def __call__(self, x):
    		y = tf.matmul(x, self.w) + self.b
    		return tf.nn.relu(y)
    
  • 从层到模型:Sequential模型

  • 动态决定张量维度:is_built

  • 模型存储和恢复:

    new_checkpoint = tf.train.Checkpoint(model=new_model)
    new_checkpoint.restore("my_checkpoint")
    
  • 装饰器:@tf.function用作call函数的规范调用

4.tensorboard可视化

5.模型的存储

  • tf.saved_model.save(my_model, 'path')
  • tf.saved_model.load

6.计算图

7.训练流程