前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >专栏 >理解CheckPoint及其在Tensorflow & Keras & Pytorch中的使用

理解CheckPoint及其在Tensorflow & Keras & Pytorch中的使用

作者头像
狼啸风云
修改于 2022-09-03 11:07:51
修改于 2022-09-03 11:07:51
5K00
代码可运行
举报
运行总次数:0
代码可运行

Checkpointing Tutorial for TensorFlow, Keras, and PyTorch

This post will demonstrate how to checkpoint your training models on FloydHub so that you can resume your experiments from these saved states.

Wait, but why?

If you've ever played a video game, you might already understand why checkpoints are useful. For example, sometimes you'll want to save your game right before a big boss castle - just in case everything goes terribly wrong inside and you need to try again. Checkpoints in machine learning and deep learning experiments are essentially the same thing - a way to save the current state of your experiment so that you can pick up from where you left off.

Trust me, you're going to have a bad time if you lose one or more of your experiments due to a power outage, OS fault, job preemption, or any other type of unexpected error. Other times, even if you don't experience an unforeseen error, you might just want just to resume a particular state of the training for a new experiment - or try different things from a given state.

That's why you need checkpoints!

But, wait - there's one more reason, and it's a big one. If you don't checkpoint your training models at the end of a job, you'll have lost all of your results! Like, they're just gone. Simply put, if you'd like to make use of your trained models, you're going to need some checkpoints.

So what is a checkpoint really?

The Keras docs provide a great explanation of checkpoints (that I'm going to gratuitously leverage here):

  • The architecture of the model, allowing you to re-create the model
  • The weights of the model
  • The training configuration (loss, optimizer, epochs, and other meta-information)
  • The state of the optimizer, allowing to resume training exactly where you left off.

Again, a checkpoint contains the information you need to save your current experiment state so that you can resume training from this point. Just like in that infernal Zelda II: The Adventure of Link game from my childhood.

Checkpoint Strategies

At this point, I'll assume I've convinced you that checkpoints need to be a vital part of your deep learning workflow. So, let's talk strategy.

You can employ different checkpoint strategies according to the type of experiment training regime you're performing:

  • Short Training Regime (minutes to hours)
  • Normal Training Regime (hours to day)
  • Long Training Regime (days to weeks)

Short Training Regime

The typical practice is to save a checkpoint only at the end of the training, or at the end of every epoch.

Normal Training Regime

In this case, it's common to save multiple checkpoints every n_epochs and keep track of the best one with respect to some validation metric that we care about. Usually, there's a fixed maximum number of checkpoints so as to not take up too much disk space (for example, restricting your maximum number of checkpoints to 10, where the new ones will replace the earliest ones).

Long Training Regime

In this type of training regime, you'll likely want to employ a similar strategy to the Normal regime - where you're saving multiple checkpoints every n_epochs and keeping track of the best one with respect to the validation metric that you care about. In this case, since the training can be very long, it's common to save checkpoints less frequently but maintain a greater number of checkpoints.

Which regime is right for me?

The tradeoff among these various strategies is between the frequency and the number of checkpoint files to keep. Let's take a look what's happening when we act over these two parameters:

FREQUENCY

CHECKPOINTS

CONS

PRO

High

High

You need a lot of space!!

You can resume very quickly in almost all the interesting training states

High

Low

You could have lost precious states

Minimize the storage space you need

Low

High

It will take time to get to intermediate states

You can resume the experiments in a lot of interesting states

Low

Low

You could have lost precious states

Minimize the storage space you need

Hopefully, now you have a good intuition about what might be the best checkpoint strategy for your training regime. It should go without saying that you can obviously develop your own custom checkpoint strategy based on your experiment needs! These are just tips and best practices that I take into consideration for my own projects.

Save and Resume on FloydHub

Now, let's dive into some code on FloydHub. I'll show you how to save checkpoints in three popular deep learning frameworks available on FloydHub: TensorFlow, Keras, and PyTorch.

Before you start, log into the FloydHub command-line-tool with the floyd logincommand, then fork and init the project:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
$ git clone https://github.com/floydhub/save-and-resume.git

$ cd save-and-resume

$ floyd init save-and-resume

For our checkpointing examples, we'll be using the Hello, World of deep learning: the MNIST classification task using a Convolutional Neural Network model.

Because it's always important to be clear about our checkpointing strategy up-front, I'll state the approach we're going to be taking:

  • Keep only one checkpoint
  • Trigger the strategy at the end of every epoch
  • Save the one with the best (maximum) validation accuracy

Considering this toy example, we can employ the Short Training Regime strategy. Feel free to adapt this for your own more complicated experiments!

The commands

Before we dive into specific working examples, let's outline the basic commands you'll need. When starting a new job, your first command will look something like this:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
floyd run \

[--gpu] \

--env <env> \

--data <your_dataset>:<mounting_point_dataset> \

"python <script_and_parameters>"

Important note: within your python script, you'll want to make sure that the checkpoint is being saved to the /output folder. FloydHub will automatically save the contents of the /output directory as a job's Output, which is how you'll be able to leverage these checkpoints to resume jobs.

Once your job has been completed, you'll then be able to mount that's job's output as an input to your next job - allowing your script to leverage the checkpoint you created in the next run of this project.

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
floyd run \

[--gpu] \

--env <env> \

--data <your_dataset>:<mounting_point_dataset> \

--data <output_of_previous_job>:<mounting_point_model> \

"python <script_and_parameters>"

Okay, enough of that. Let's see how to make this tangible using three of the most popular frameworks on FloydHub.

TensorFlow

View full example on a FloydHub Jupyter Notebook

TensorFlow provides different ways to save and resume a checkpoint. In our example, we will use the tf.Estimator API, which uses tf.train.Savertf.train.CheckpointSaverHook and tf.saved_model.builder.SavedModelBuilder behind the scenes.

To be more clear, the tf.Estimator API uses the first function to save the checkpoint, the second one to act according to the adopted checkpointing strategy, and the last one to export the model to be served with export_savedmodel() method.

Let's dig in.

Saving a TensorFlow checkpoint

Before initializing an Estimator, we have to define the checkpoint strategy. To do so, we have to create a configuration for the Estimator using the tf.estimator.RunConfigAPI. Here's an example of how we might do this:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
# Save the checkpoint in the /output folder

filepath = "/output/mnist_convnet_model"


# Checkpoint Strategy configuration

run_config = tf.contrib.learn.RunConfig(

model_dir=filepath,

keep_checkpoint_max=1)

In this way, we're telling the estimator which directory to save or resume a checkpoint from, and also how many checkpoints to keep.

Next, we have to provide this configuration at the initialization of the Estimator:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
# Create the Estimator

mnist_classifier = tf.estimator.Estimator(

model_fn=cnn_model_fn, config=run_config)

That's it. Seriously. We're now set up to save checkpoints in our TensorFlow code.

Resuming a TensorFlow checkpoint

Guess what? We're also already set up to resume from checkpoints in our next experiment run. If the Estimator finds a checkpoint inside the given model folder, it will load from the last checkpoint.

Okay, let me try

Don't take my word for it - try it out yourself. Here are the steps to run the TensorFlow checkpointing example on FloydHub.

Via FloydHub's Command Mode

First time training command:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
floyd run \

--gpu \

--env tensorflow-1.3 \

--data redeipirati/datasets/mnist/1:input \

'python tf_mnist_cnn.p

y'
  • The --env flag specifies the environment that this project should run on (Tensorflow 1.3.0 + Keras 2.0.6 on Python3.6)
  • The --data flag specifies that the pytorch-mnist dataset should be available at the /input directory
  • The --gpu flag is actually optional here - unless you want to start right away with running the code on a GPU machine

Resuming from your checkpoint:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
floyd run \

--gpu \

--env tensorflow-1.3 \

--data redeipirati/datasets/mnist/1:input \

--data <your-username>/projects/save-and-resume/<jobs>/output:/model \

'python tf_mnist_cnn.py'
  • The --env flag specifies the environment that this project should run on (Tensorflow 1.3.0 + Keras 2.0.6 on Python3.6)
  • The first --data flag specifies that the pytorch-mnist dataset should be available at the /input directory
  • The second --data flag specifies that the output of a previus Job should be available at the /model directory
  • The --gpu flag is actually optional here - unless you want to start right away with running the code on a GPU machine

Via FloydHub's Jupyter Notebook Mode

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
floyd run \

--gpu \

--env tensorflow-1.3 \

--data redeipirati/datasets/mnist/1:input \

--mode jupyter
  • The --env flag specifies the environment that this project should run on (Tensorflow 1.3.0 + Keras 2.0.6 on Python3.6)
  • The --data flag specifies that the pytorch-mnist dataset should be available at the /input directory
  • The --gpu flag is actually optional here - unless you want to start right away with running the code on a GPU machine
  • The --mode flag specifies that this job should provide a Jupyter notebook instance

Resuming from your checkpoint:

Just add --data <your-username>/projects/save-and-resume/<jobs>/output:/modelto the previous command if you want to load a checkpoint from a previous Job in your Jupyter notebook.

Keras

View full example on a FloydHub Jupyter Notebook

Keras provides a great API for saving and loading checkpoints. Let's take a look:

Saving a Keras checkpoint

Keras provides a set of functions called callbacks: you can think of callbacks as events that will be triggered at certain training states. The callback we need for checkpointing is the ModelCheckpoint which provides all the features we need according to the checkpointing strategy we adopted in our example.

Note: this function will only save the model's weights - if you want to save the entire model or some of the components, you can take a look at the Keras docs on saving a model.

First up, we have to import the callback functions:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
from keras.callbacks import ModelCheckpoint

Next, just before the call to model.fit(...), it's time to prepare the checkpoint strategy.

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
# Save the checkpoint in the /output folder

filepath = "/output/mnist-cnn-best.hdf5"


# Keep only a single checkpoint, the best over test accuracy.

checkpoint = ModelCheckpoint(filepath,

monitor='val_acc',

verbose=1,

save_best_only=True,

mode='max')
  • filepath="/output/mnist-cnn-best.hdf5": Remember, FloydHub will save the contents of /output folder! See more on job output in the FloydHub docs,
  • monitor='val_acc': This is the metric we care about - validation accuracy,
  • verbose=1: It will print more information
  • save_best_only=True: Keep only the best checkpoint (in terms of maximum validation accurancy)
  • mode='max': Save the checkpoint with max validation accuracy

By default, the period (or checkpointing frequency) is set to 1, which means at the end of every epoch.

For more information (such as filepath formatting options, checkpointing period, and more), you can explore the Keras ModelCheckpoint API.

Finally, we are ready to see this checkpointing strategy applied during model training. In order to do this, we need to pass the callback variable to the model.fit(...) call:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
# Train

model.fit(x_train, y_train,

batch_size=batch_size,

epochs=epochs,

verbose=1,

validation_data=(x_test, y_test),

callbacks=[checkpoint]) # <- Apply our checkpoint strategy

According to our chosen strategy, you will see:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
# This line when the training reach a new max

Epoch < n_epoch >: val_acc improved from < previous val_acc > to < new max val_acc >, saving model to /output/mnist-cnn-best.hdf5


# Or this line

Epoch < n_epoch >: val_acc did not improve

That's it - you're now set up to save your Keras checkpoints.

Resuming a Keras checkpoint

Keras models provide the load_weights() method, which loads the weights from a hdf5 file.

To load the model's weights, you just need to add this line after the model definition:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
... # Model Definition


model.load_weights(resume_weights)

Okay, let me try

Here's how you can do run this Keras example on FloydHub:

Via FloydHub's Command Mode

First time training command:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
floyd run \

--gpu \

--env tensorflow-1.3 \

'python keras_mnist_cnn.py'
  • The --env flag specifies the environment that this project should run on (Tensorflow 1.3.0 + Keras 2.0.6 on Python3.6)
  • The --gpu flag is actually optional here - unless you want to start right away with running the code on a GPU machine

Keras provides an API to handle MNIST data, so we can skip the dataset mounting in this case.

Resuming from your checkpoint:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
floyd run \

--gpu \

--env tensorflow-1.3 \

--data <your-username>/projects/save-and-resume/<jobs>/output:/model \

'python keras_mnist_cnn.py'
  • The --env flag specifies the environment that this project should run on (Tensorflow 1.3.0 + Keras 2.0.6 on Python3.6)
  • The --data flag specifies that the output of a previus Job should be available at the /model directory
  • The --gpu flag is actually optional here - unless you want to start right away with running the code on a GPU machine

Via FloydHub's Jupyter Notebook Mode

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
floyd run \

--gpu \

--env tensorflow-1.3 \

--mode jupyter
  • The --env flag specifies the environment that this project should run on (Tensorflow 1.3.0 + Keras 2.0.6 on Python3.6)
  • The --gpu flag is actually optional here - unless you want to start right away with running the code on a GPU machine
  • The --mode flag specifies that this job should provide us a Jupyter notebook.

Resuming from your checkpoint:

Just add --data <your-username>/projects/save-and-resume/<jobs>/output:/model if you want to load a checkpoint from a previous job.

PyTorch

View full example on a FloydHub Jupyter Notebook

Unfortunately, at the moment, PyTorch does not have as easy of an API as Keras for checkpointing. We'll need to write our own solution according to our chosen checkpointing strategy.

Saving a PyTorch checkpoint

PyTorch does not provide an all-in-one API to defines a checkpointing strategy, but it does provide a simple way to save and resume a checkpoint. According the official docs about semantic serialization, the best practice is to save only the weights - due to a code refactoring issue.

Therefore, let's take a look at how to save the model weights in PyTorch.

First up, let's define a save_checkpoint function which handles all the instructions about the number of checkpoints to keep and the serialization on file:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
def save_checkpoint(state, is_best, filename='/output/checkpoint.pth.tar'):

"""Save checkpoint if a new best is achieved"""

if is_best:

print ("=> Saving a new best")

torch.save(state, filename) # save checkpoint

else:

print ("=> Validation Accuracy did not improve")

Then, inside the training (which is usually a for-loop of the number of epochs), we define the checkpoint frequency (in our case, at the end of every epoch) and the information we'd like to store (the epochs, model weights, and best accuracy achieved):

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
...


# Training the Model

for epoch in range(num_epochs):

train(...) # Train

acc = eval(...) # Evaluate after every epoch


# Some stuff with acc(accuracy)

...


# Get bool not ByteTensor

is_best = bool(acc.numpy() > best_accuracy.numpy())

# Get greater Tensor to keep track best acc

best_accuracy = torch.FloatTensor(max(acc.numpy(), best_accuracy.numpy()))

# Save checkpoint if is a new best

save_checkpoint({

'epoch': start_epoch + epoch + 1,

'state_dict': model.state_dict(),

'best_accuracy': best_accuracy

}, is_best)

That's it! You can now save checkpoints in your PyTorch experiments.

Resuming a PyTorch checkpoint

To resume a PyTorch checkpoint, we have to load the weights and the meta information we need before the training:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
# cuda = torch.cuda.is_available()

if cuda:

checkpoint = torch.load(resume_weights)

else:

# Load GPU model on CPU

checkpoint = torch.load(resume_weights,

map_location=lambda storage,

loc: storage)

start_epoch = checkpoint['epoch']

best_accuracy = checkpoint['best_accuracy']

model.load_state_dict(checkpoint['state_dict'])

print("=> loaded checkpoint '{}' (trained for {} epochs)".format(resume_weights, checkpoint['epoch']))

For more information on loading GPU-trained weights on a CPU instance, you can check out this PyTorch discussion.

Okay, let me try

Here's how you can do run this PyTorch example on FloydHub:

Via FloydHub's Command Mode

First time training command:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
floyd run \

--gpu \

--env pytorch-0.2 \

--data redeipirati/datasets/pytorch-mnist/1:input \

'python pytorch_mnist_cnn.py'
  • The --env flag specifies the environment that this project should run on (PyTorch 0.2.0 on Python 3)
  • The --data flag specifies that the pytorch-mnist dataset should be available at the /input directory
  • The --gpu flag is actually optional here - unless you want to start right away with running the code on a GPU machine

Resuming from your checkpoint:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
floyd run \

--gpu \

--env pytorch-0.2 \

--data redeipirati/datasets/pytorch-mnist/1:input \

--data <your-username>/projects/save-and-resume/<jobs>/output:/model \

'python pytorch_mnist_cnn.py'
  • The --env flag specifies the environment that this project should run on (PyTorch 0.2.0 on Python 3)
  • The first --data flag specifies that the pytorch-mnist dataset should be available at the /input directory
  • The second --data flag specifies that the output of a previus Job should be available at the /model directory
  • The --gpu flag is actually optional here - unless you want to start right away with running the code on a GPU machine

Via FloydHub's Jupyter Notebook Mode

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
floyd run \

--gpu \

--env pytorch-0.2 \

--data redeipirati/datasets/pytorch-mnist/1:input \

--mode jupyter
  • The --env flag specifies the environment that this project should run on (PyTorch 0.2.0 on Python 3)
  • The --data flag specifies that the pytorch-mnist dataset should be available at the /input directory
  • The --gpu flag is actually optional here - unless you want to start right away with running the code on a GPU machine
  • The --mode flag specifies that this job should provide us a Jupyter notebook.

Resuming from your checkpoint:

Just add --data <your-username>/projects/save-and-resume/<jobs>/output:/model if you want to load a checkpoint from a previous Job.

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2020/01/18 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
暂无评论
推荐阅读
实时消息传输协议 RTMP(Real Time Messaging Protocol)
http://blog.csdn.net/defonds/article/details/17403225
bear_fish
2018/09/20
2.7K0
实时消息传输协议 RTMP(Real Time Messaging Protocol)
直播协议的选择:RTMP vs. HLS
随着直播业务的兴起,越来越多的直播平台开始涌现,这火热的程度好像一个应用不带上直播业务出来都不好意思跟人打招呼。想要做一个直播业务,主要包括三个部分:采集推流端、流媒体服务端、播放端。这里不多说,就主要结合 iOS 平台,从观看端出发,介绍一下对直播协议的选择。
音视频牛哥
2019/09/19
4.1K0
扫盲文章:AMF,RTMP,RTMPT,RTMPS
AMF AMF(是Action Message Format的缩写)是在flash和flex中与远程服务端交换数据的一种格式. 它是二进制格式,Flash应用与服务端或数据库通过RPC交换数据时,通常都采用这种格式。 AMF 1 诞生于Flash Player6,发展到现在已经变成了了AMF3 RTMP RTMP是Real-Time Messaging Protocol(实时消息传送协议)的缩写,它是Adobe Systems公司为Flash播放器和服务器之间音频、视频和数据传输开发的私有协议。 RTMP协
菩提树下的杨过
2018/01/23
2.1K0
流媒体及直播相关知识
本文主要讲解流媒体及其直播相关知识,所涉及的知识内容比较浅显,主要是做个简单的了解。
Gnep@97
2023/09/23
6830
流媒体及直播相关知识
视频协议学习:推流拉流都擅长的 RTMP
腾讯云开发者社区
2017/05/03
10K0
视频协议学习:推流拉流都擅长的 RTMP
一文说透RTMP、RTSP、RTP、HLS、MPEG-DASH
常与RTSP一起用于音视频流传输,确保媒体数据能够准确、高效地传输到目标终端并进行解码播放。
音视频牛哥
2024/09/24
6.1K0
一文说透RTMP、RTSP、RTP、HLS、MPEG-DASH
全面进阶 H5 直播(上)
如果我们想要理解 HTML5 视频,首先需要知道,你应该知道,但你不知道的内容?那怎么去判断呢? ok,很简单,我提几个问题即可,如果某些童鞋知道答案的话,可以直接跳过。 你知道 ogg,mp4,flv,webm(前面加个点 .)这些叫做什么吗? 那 FLV,MPEG-4,VP8 是啥? 如果,基友问你要片源,你会说我这是 mp4 的还是 MPEG-4 的呢? 当然,还有一些问题,我这里就不废话了。上面主要想说的其实就两个概念:视频文件格式(容器格式),视频编解码器(视频编码格式)。当然,还有另外一种,叫做
腾讯IVWEB团队
2018/01/15
9.8K1
全面进阶 H5 直播(上)
使用WebRTC作为RTMP的替代方案
 点击上方“LiveVideoStack”关注我们 ▲扫描图中二维码或点击阅读原文▲ 了解音视频技术大会更多信息 ---- 作者:Barry Owen 翻译:Alex 技术审校:刘连响 WebRTC 影音探索 #014# 2020年,Adobe宣布停止对 Flash播放器的支持。Flash历经多年终于走向终结,虽然是众望所归,但它的退出却对存在于许多流媒体工作流程中的一项重要技术——RTMP( Real-Time Messaging Protocol)影响重大。RTMP最初设计用于向Adobe Fl
LiveVideoStack
2022/07/12
3K0
使用WebRTC作为RTMP的替代方案
流视频协议
video streaming protocol - 流视频协议是由于流式传输需要将音视频分割成小块,按顺序发送并在接收时播放
vanguard
2020/05/29
2.3K0
RTMP协议详解及Wiresahrk抓包分析
本文主要讲解 RTMP 协议,并通过 wireshark 对 RTMP 进行抓包并分析。
Gnep@97
2023/11/08
5K0
RTMP协议详解及Wiresahrk抓包分析
一套在线直播源码中的推流和传输常用协议
可能大部分人认为,只要拥有一套优质的在线直播源码,就可以顺利进行开发和搭建等步骤了。但实际上,整个直播过程主要涉及到采集、处理、编码、封装、推流、传输、解码等一系列过程,本次就重点说推流和传输的问题。
布谷鸟小刘
2021/01/28
7170
流媒体协议介绍(rtp/rtcp/rtsp/rtmp/mms/hls)
         Real-time Transport Protocol)是用于Internet上针对多媒体数据流的一种传输层协议。RTP协议详细说明了在互联网上传递音频和视频的标准数据包格式。RTP协议常用于流媒体系统(配合RTCP协议),视频会议和一键通(Push to Talk)系统(配合H.323或SIP),使它成为IP电话产业的技术基础。RTP协议和RTP控制协议RTCP一起使用,而且它是建立在UDP协议上的。 
雪影
2018/08/02
6.6K0
流媒体协议介绍(rtp/rtcp/rtsp/rtmp/mms/hls)
RTSP和RTMP协议有什么区别?RTSP为什么常用于安防监控摄像头行业,而视频直播却只使用RTMP推流?
RTSP(Real Time Streaming Protocol)是一种用于控制实时流媒体传输的网络协议。它允许客户端与服务器进行交互,控制流媒体的播放、暂停、停止、倒放、快进等操作。RTSP协议可以用于音频、视频等多种流媒体数据的传输。
csdn博主eguid_1
2024/01/25
5.5K0
用一首歌曲来谱写RTMP协议分析
最近在重温由W.Richard Stevens 的传世之作《TCP/IP详解》,看到第12章TCP ,基于传输层有TCP 、 UDP 、 TLS 、DCCP 、SCTP 、RSVP 、PPTP等,那我好奇那基于TCP有哪些协议呢?在Google里面查找了一下,有一个协议映入眼帘 RTMP ,RTMP(实时消息传输协议)是Adobe 公司开发的一个基于TCP的应用层协议,主要用来在Flash/AIR平台和支持RTMP协议的流媒体/交互服务器之间进行音视频和数据通信。RTMP协议没听过啊,一下子激起了我想要揭开它的面纱的冲动,大概研究了RTMP协议整整3天时间,试图想要找出一些漏洞出来,幸运的是我找到了!很鸡冻,下面就是我对此协议的分析。
FB客服
2018/09/21
6480
用一首歌曲来谱写RTMP协议分析
理解直播及其工作原理
直播是指通过互联网实时传输演出的音频和视频内容。随着实时视频的流行,直播俨然已成为众多企业和组织市场战略的重要组成部分。直播可用于活动(赛事)直播、提供客户服务以及举行网络研讨会等一切内容。
LiveVideoStack
2022/02/11
2K0
理解直播及其工作原理
直播软件开发的直播平台源码搭建中流媒体技术详解
随着移动互联网的发展,国内也涌现大大小小十几款视频直播app。以王思聪投资的17在2015年的爆红为代表,视频移动直播浮出水面,再到后来的映客、花椒、蜜友圈等等,直播自媒体时代的快速发展改变了人们传统的生活习惯和传统商业模式。
云豹短视频嘉兴
2020/08/28
1.1K0
直播软件开发的直播平台源码搭建中流媒体技术详解
(零)音视频技术基础知识
耽误了很久,一直想写音视频开发的教程,一方面,音视频的发展正在向各个行业扩展,从教育的远程授课,交通的人脸识别,医疗的远程就医等,音视频方向已经占据一个相当重要的位置,而音视频真正入门的文章又少之甚少,一个刚毕业小白可能很难切入理解,因为音视频中涉及大量理论知识,而代码的书写需要结合这些理论,所以搞懂音视频,编解码等理论知识至关重要。另一方面,公司的业务也在逐渐向音视频靠拢,我需要先将积累的知识点重新梳理后分享给其他同学。
sweet说好的幸福
2020/12/23
1.5K0
(零)音视频技术基础知识
前端中的直播
因为公司是做在线抓娃娃的,涉及到直播推流这一部分的工作。之前一直都是在App上面进行游戏,所以关于直播这一部分也是与安卓与IOS有关,与前端是没有关系的。但是现在新的需求就是要求这个在线抓娃娃要能够在网页上面进行游戏。所以,我的事情来了。对于没有涉及到前端音视频的这部分的需求,所以初入这一行,还是有点马马虎虎,花了一周多的时间终于是弄明白了。
踏浪
2019/11/05
4.9K0
全面进阶 H5 直播
如果我们想要理解 HTML5 视频,首先需要知道,你应该知道,但你不知道的内容?那怎么去判断呢?
腾讯IVWEB团队
2020/06/27
2.8K0
一文详解GB28181、RTSP、RTMP
GB28181 即 GB/T28181—2016《公共安全视频监控联网系统信息传输、交换、控制技术要求》。它是公安部提出的公共安全行业标准,在视频监控领域具有重要地位。
音视频牛哥
2024/09/24
4.7K0
一文详解GB28181、RTSP、RTMP
相关推荐
实时消息传输协议 RTMP(Real Time Messaging Protocol)
更多 >
LV.3
这个人很懒,什么都没有留下~
目录
  • So what is a checkpoint really?
  • Checkpoint Strategies
    • Short Training Regime
    • Normal Training Regime
    • Long Training Regime
      • Which regime is right for me?
  • Save and Resume on FloydHub
    • The commands
  • TensorFlow
    • Saving a TensorFlow checkpoint
    • Resuming a TensorFlow checkpoint
    • Okay, let me try
      • Via FloydHub's Command Mode
      • Via FloydHub's Jupyter Notebook Mode
  • Keras
    • Saving a Keras checkpoint
    • Resuming a Keras checkpoint
    • Okay, let me try
      • Via FloydHub's Command Mode
      • Via FloydHub's Jupyter Notebook Mode
  • PyTorch
    • Saving a PyTorch checkpoint
    • Resuming a PyTorch checkpoint
    • Okay, let me try
      • Via FloydHub's Command Mode
      • Via FloydHub's Jupyter Notebook Mode
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档