欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Tensorflow高性能數(shù)據(jù)優(yōu)化增強工具Pipeline使用詳解

 更新時間:2022年11月01日 11:09:36   作者:ronghuaiyang  
這篇文章主要為大家介紹了Tensorflow高性能數(shù)據(jù)優(yōu)化增強工具Pipeline使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪

安裝方法

給大家介紹一個非常好用的TensorFlow數(shù)據(jù)pipeline工具。

高性能的Tensorflow Data Pipeline,使用SOTA的增強和底層優(yōu)化。

pip install tensorflow-addons==0.11.2
pip install tensorflow==2.2.0
pip install sklearn

功能

  • High Performance tf.data pipline
  • Core tensorflow support for high performance
  • Classification data support
  • Bbox data support
  • Keypoints data support
  • Segmentation data support
  • GridMask in core tf2.x
  • Mosiac Augmentation in core tf2.x
  • CutOut in core tf2.x
  • Flexible and easy configuration
  • Gin-config support

高級用戶部分

用例1,為訓(xùn)練創(chuàng)建數(shù)據(jù)Pipeline

from pipe import Funnel                                                         
from bunch import Bunch                                                         
"""                                                                             
Create a Funnel for the Pipeline!                                               
"""                                                                             
# Config for Funnel
config = {                                                                      
    "batch_size": 2,                                                            
    "image_size": [512,512],                                                    
    "transformations": {                                                        
        "flip_left_right": None,                                                
        "gridmask": None,                                                       
        "random_rotate":None,                                                   
    },                                                                          
    "categorical_encoding":"labelencoder"                                       
}                                                                               
config = Bunch(config)                                                          
pipeline = Funnel(data_path="testdata", config=config, datatype="categorical")  
pipeline = pipeline.dataset(type="train")                                       
# Pipline ready to use, iter over it to use.
# Custom loop example.
for data in pipeline:
    image_batch , label_batch = data[0], data[1]
    # you can use _loss = loss(label_batch,model.predict(image_batch))
    # calculate gradients on loss and optimize the model.
    print(image_batch,label_batch)                                      

用例2,為驗證創(chuàng)建數(shù)據(jù)Pipeline

from pipe import Funnel                                                         
from bunch import Bunch                                                         
"""                                                                             
Create a Funnel for the Pipeline!                                               
"""                                                                             
# Config for Funnel
config = {                                                                      
    "batch_size": 1,                                                            
    "image_size": [512,512],                                                    
    "transformations": {                                                                                                       
    },                                                                          
    "categorical_encoding":"labelencoder"                                       
}                                                                               
config = Bunch(config)                                                          
pipeline = Funnel(data_path="testdata", config=config, datatype="categorical", training=False)  
pipeline = pipeline.dataset(type="val")                                       
# use pipeline to validate your data on model.
loss = []
for data in pipeline:
    image_batch , actual_label_batch = data[0], data[1]
    # pred_label_batch = model.predict(image_batch)
    # loss.append(calc_loss(actual_label_batch,pred_label_batch))
    print(image_batch,label_batch)                                     

初學(xué)者部分

Keras 兼容性

使用keras model.fit來構(gòu)建非常簡單的pipeline。

import tensorflow as tf
from pipe import Funnel
"""
Create a Funnel for the Pipeline!
"""
config = {
    "batch_size": 2,
    "image_size": [100, 100],
    "transformations": {
        "flip_left_right": None,
        "gridmask": None,
        "random_rotate": None,
    },
    "categorical_encoding": "labelencoder",
}
pipeline = Funnel(data_path="testdata", config=config, datatype="categorical")
pipeline = pipeline.dataset(type="train")
# Create Keras model
model = tf.keras.applications.VGG16(
    include_top=True, weights=None,input_shape=(100,100,3),
    pooling=None, classes=2, classifier_activation='sigmoid'
)
# compile
model.compile(loss='mse', optimizer='adam')
# pass pipeline as iterable
model.fit(pipeline , batch_size=2,steps_per_epoch=5,verbose=1)

配置

  • image_size - pipeline的圖像尺寸。
  • batch_size - pipeline的Batch size。
  • transformations - 應(yīng)用數(shù)據(jù)增強字典中的對應(yīng)關(guān)鍵字。
  • categorical_encoding - 對類別數(shù)據(jù)進(jìn)行編碼  - ('labelencoder' , 'onehotencoder').

增強:

GridMask

在輸入圖像上創(chuàng)建gridmask,并在范圍內(nèi)定義旋轉(zhuǎn)。

參數(shù):

ratio - 空間上的網(wǎng)格比例

fill - 填充值fill value

rotate - 旋轉(zhuǎn)的角度范圍

MixUp

使用給定的alpha值,將兩個隨機采樣的圖像和標(biāo)簽進(jìn)行混合。

參數(shù):

alpha - 在混合時使用的值。

RandomErase

在給定的圖像上的隨機位置擦除一個隨機的矩形區(qū)域。

參數(shù):

prob - 在圖像上進(jìn)行隨機的概率。

CutMix

在給定圖像上對另一個隨機采樣的圖像進(jìn)行隨機的縮放,再以完全覆蓋的方式貼到這個給定圖像上。

params:

prob - 在圖像上進(jìn)行CutMix的概率。

Mosaic

把4張輸入圖像組成一張馬賽克圖像。

參數(shù):

prob - 進(jìn)行Mosaic的概率。

CutMix , CutOut, MixUp

Mosaic

Grid Mask

以上就是Tensorflow高性能數(shù)據(jù)優(yōu)化增強工具Pipeline使用詳解的詳細(xì)內(nèi)容,更多關(guān)于Tensorflow數(shù)據(jù)工具Pipeline的資料請關(guān)注腳本之家其它相關(guān)文章!

相關(guān)文章

  • 在Python的Flask框架中實現(xiàn)單元測試的教程

    在Python的Flask框架中實現(xiàn)單元測試的教程

    這篇文章主要介紹了在Python的Flask框架中實現(xiàn)單元測試的教程,屬于自動化部署的方面,可以給debug工作帶來諸多便利,需要的朋友可以參考下
    2015-04-04
  • python 爬取馬蜂窩景點翻頁文字評論的實現(xiàn)

    python 爬取馬蜂窩景點翻頁文字評論的實現(xiàn)

    這篇文章主要介紹了python 爬取馬蜂窩景點翻頁文字評論的實現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-01-01
  • Python利用pangu模塊實現(xiàn)文本格式化小工具

    Python利用pangu模塊實現(xiàn)文本格式化小工具

    其實使用pangu做文本格式標(biāo)準(zhǔn)化的業(yè)務(wù)代碼在之前就實現(xiàn)了,主要能夠?qū)⒅形奈谋疚臋n中的文字、標(biāo)點符號等進(jìn)行標(biāo)準(zhǔn)化。但是為了方便起來我們這里使用了Qt5將其做成了一個可以操作的頁面應(yīng)用,需要的可以了解一下
    2022-10-10
  • 詳解Python GUI工具取色器

    詳解Python GUI工具取色器

    作為Python開發(fā)者,你遲早都會用到圖形用戶界面來開發(fā)應(yīng)用。本文將推薦Python GUI工具取色器的一些知識,感興趣的朋友一起看看吧
    2021-06-06
  • TensorFlow數(shù)據(jù)輸入的方法示例

    TensorFlow數(shù)據(jù)輸入的方法示例

    這篇文章主要介紹了TensorFlow數(shù)據(jù)輸入的方法示例,主要介紹了4種方法,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-06-06
  • python代碼實現(xiàn)TSNE降維數(shù)據(jù)可視化教程

    python代碼實現(xiàn)TSNE降維數(shù)據(jù)可視化教程

    今天小編就為大家分享一篇python代碼實現(xiàn)TSNE降維數(shù)據(jù)可視化教程,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-02-02
  • python引用DLL文件的方法

    python引用DLL文件的方法

    這篇文章主要介紹了python引用DLL文件的方法,涉及Python調(diào)用dll文件的相關(guān)技巧,需要的朋友可以參考下
    2015-05-05
  • tensorflow模型保存、加載之變量重命名實例

    tensorflow模型保存、加載之變量重命名實例

    今天小編就為大家分享一篇tensorflow模型保存、加載之變量重命名實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-01-01
  • 在Django admin中編輯ManyToManyField的實現(xiàn)方法

    在Django admin中編輯ManyToManyField的實現(xiàn)方法

    今天小編就為大家分享一篇在Django admin中編輯ManyToManyField的實現(xiàn)方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-08-08
  • Python中變量的輸入輸出實例代碼詳解

    Python中變量的輸入輸出實例代碼詳解

    這篇文章主要介紹了Python中變量的輸入輸出問題,本文通過實例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價值 ,需要的朋友可以參考下
    2019-07-07

最新評論