最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

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

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

安裝方法

給大家介紹一個非常好用的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ù)進行編碼  - ('labelencoder' , 'onehotencoder').

增強:

GridMask

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

參數(shù):

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

fill - 填充值fill value

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

MixUp

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

參數(shù):

alpha - 在混合時使用的值。

RandomErase

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

參數(shù):

prob - 在圖像上進行隨機的概率。

CutMix

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

params:

prob - 在圖像上進行CutMix的概率。

Mosaic

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

參數(shù):

prob - 進行Mosaic的概率。

CutMix , CutOut, MixUp

Mosaic

Grid Mask

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

相關(guān)文章

最新評論

三亚市| 呼玛县| 定州市| 乾安县| 桃江县| 寻乌县| 麻城市| 平定县| 仙桃市| 商城县| 临西县| 汝城县| 浦东新区| 苍溪县| 仪征市| 扶绥县| 中西区| 兴山县| 汕尾市| 梅州市| 陵川县| 剑川县| 邛崃市| 乾安县| 苍梧县| 桑日县| 无为县| 通州区| 太康县| 桦川县| 治县。| 仁化县| 浦北县| 逊克县| 中方县| 建阳市| 会东县| 东明县| 聊城市| 镇雄县| 江安县|