在线观看www成人影院-在线观看www日本免费网站-在线观看www视频-在线观看操-欧美18在线-欧美1级

0
  • 聊天消息
  • 系統消息
  • 評論與回復
登錄后你可以
  • 下載海量資料
  • 學習在線課程
  • 觀看技術視頻
  • 寫文章/發帖/加入社區
會員中心
創作中心

完善資料讓更多小伙伴認識你,還能領取20積分哦,立即完善>

3天內不再提示

一個實用的GitHub項目:TensorFlow-Cookbook

DPVg_AI_era ? 來源:lq ? 2019-02-19 09:04 ? 次閱讀

今天為大家推薦一個實用的GitHub項目:TensorFlow-Cookbook。 這是一個易用的TensorFlow代碼集,包含了對GAN有用的一些通用架構和函數。

今天為大家推薦一個實用的GitHub項目:TensorFlow-Cookbook。

這是一個易用的TensorFlow代碼集,作者是來自韓國的AI研究科學家Junho Kim,內容涵蓋了譜歸一化卷積、部分卷積、pixel shuffle、幾種歸一化函數、 tf-datasetAPI,等等。

作者表示,這個repo包含了對GAN有用的一些通用架構和函數。

項目正在進行中,作者將持續為其他領域添加有用的代碼,目前正在添加的是 tf-Eager mode的代碼。歡迎提交pull requests和issues。

Github地址 :

https://github.com/taki0112/Tensorflow-Cookbook

如何使用

Import

ops.py

operations

from ops import *

utils.py

image processing

from utils import *

Network template

def network(x, is_training=True, reuse=False, scope="network"): with tf.variable_scope(scope, reuse=reuse): x = conv(...) ... return logit

使用DatasetAPI向網絡插入數據

Image_Data_Class = ImageData(img_size, img_ch, augment_flag) trainA = trainA.map(Image_Data_Class.image_processing, num_parallel_calls=16) trainA = trainA.shuffle(buffer_size=10000).prefetch(buffer_size=batch_size).batch(batch_size).repeat() trainA_iterator = trainA.make_one_shot_iterator() data_A = trainA_iterator.get_next() logit = network(data_A)

了解更多,請閱讀:

https://github.com/taki0112/Tensorflow-DatasetAPI

Option

padding='SAME'

pad = ceil[ (kernel - stride) / 2 ]

pad_type

'zero' or 'reflect'

sn

usespectral_normalizationor not

Ra

userelativistic ganor not

loss_func

gan

lsgan

hinge

wgan

wgan-gp

dragan

注意

如果你不想共享變量,請以不同的方式設置所有作用域名稱。

權重(Weight)

weight_init = tf.truncated_normal_initializer(mean=0.0, stddev=0.02) weight_regularizer = tf.contrib.layers.l2_regularizer(0.0001) weight_regularizer_fully = tf.contrib.layers.l2_regularizer(0.0001)

初始化(Initialization)

Xavier: tf.contrib.layers.xavier_initializer()

He: tf.contrib.layers.variance_scaling_initializer()

Normal: tf.random_normal_initializer(mean=0.0, stddev=0.02)

Truncated_normal: tf.truncated_normal_initializer(mean=0.0, stddev=0.02)

Orthogonal: tf.orthogonal_initializer(1.0) / # if relu = sqrt(2), the others = 1.0

正則化(Regularization)

l2_decay: tf.contrib.layers.l2_regularizer(0.0001)

orthogonal_regularizer: orthogonal_regularizer(0.0001) & orthogonal_regularizer_fully(0.0001)

卷積(Convolution)

basic conv

x = conv(x, channels=64, kernel=3, stride=2, pad=1, pad_type='reflect', use_bias=True, sn=True, scope='conv')

partial conv (NVIDIAPartial Convolution)

x = partial_conv(x, channels=64, kernel=3, stride=2, use_bias=True, padding='SAME', sn=True, scope='partial_conv')

dilated conv

x = dilate_conv(x, channels=64, kernel=3, rate=2, use_bias=True, padding='SAME', sn=True, scope='dilate_conv')

Deconvolution

basic deconv

x = deconv(x, channels=64, kernel=3, stride=2, padding='SAME', use_bias=True, sn=True, scope='deconv')

Fully-connected

x = fully_conneted(x, units=64, use_bias=True, sn=True, scope='fully_connected')

Pixel shuffle

x = conv_pixel_shuffle_down(x, scale_factor=2, use_bias=True, sn=True, scope='pixel_shuffle_down') x = conv_pixel_shuffle_up(x, scale_factor=2, use_bias=True, sn=True, scope='pixel_shuffle_up')

down===> [height, width] -> [height // scale_factor, width // scale_factor]

up===> [height, width] -> [height * scale_factor, width * scale_factor]

Block

residual block

x = resblock(x, channels=64, is_training=is_training, use_bias=True, sn=True, scope='residual_block') x = resblock_down(x, channels=64, is_training=is_training, use_bias=True, sn=True, scope='residual_block_down') x = resblock_up(x, channels=64, is_training=is_training, use_bias=True, sn=True, scope='residual_block_up')

down===> [height, width] -> [height // 2, width // 2]

up===> [height, width] -> [height * 2, width * 2]

attention block

x = self_attention(x, channels=64, use_bias=True, sn=True, scope='self_attention') x = self_attention_with_pooling(x, channels=64, use_bias=True, sn=True, scope='self_attention_version_2') x = squeeze_excitation(x, channels=64, ratio=16, use_bias=True, sn=True, scope='squeeze_excitation') x = convolution_block_attention(x, channels=64, ratio=16, use_bias=True, sn=True, scope='convolution_block_attention')

Normalization

Normalization

x = batch_norm(x, is_training=is_training, scope='batch_norm') x = instance_norm(x, scope='instance_norm') x = layer_norm(x, scope='layer_norm') x = group_norm(x, groups=32, scope='group_norm') x = pixel_norm(x) x = batch_instance_norm(x, scope='batch_instance_norm') x = condition_batch_norm(x, z, is_training=is_training, scope='condition_batch_norm'): x = adaptive_instance_norm(x, gamma, beta):

如何使用condition_batch_norm,請參考:

https://github.com/taki0112/BigGAN-Tensorflow

如何使用adaptive_instance_norm,請參考:

https://github.com/taki0112/MUNIT-Tensorflow

Activation

x = relu(x) x = lrelu(x, alpha=0.2) x = tanh(x) x = sigmoid(x) x = swish(x)

Pooling & Resize

x = up_sample(x, scale_factor=2) x = max_pooling(x, pool_size=2) x = avg_pooling(x, pool_size=2) x = global_max_pooling(x) x = global_avg_pooling(x) x = flatten(x) x = hw_flatten(x)

Loss

classification loss

loss, accuracy = classification_loss(logit, label)

pixel loss

loss = L1_loss(x, y) loss = L2_loss(x, y) loss = huber_loss(x, y) loss = histogram_loss(x, y)

histogram_loss表示圖像像素值在顏色分布上的差異。

gan loss

d_loss = discriminator_loss(Ra=True, loss_func='wgan-gp', real=real_logit, fake=fake_logit) g_loss = generator_loss(Ra=True, loss_func='wgan_gp', real=real_logit, fake=fake_logit)

如何使用gradient_penalty,請參考:

https://github.com/taki0112/BigGAN-Tensorflow/blob/master/BigGAN_512.py#L180

kl-divergence (z ~ N(0, 1))

loss = kl_loss(mean, logvar)

Author

Junho Kim

Github地址 :

https://github.com/taki0112/Tensorflow-Cookbook

聲明:本文內容及配圖由入駐作者撰寫或者入駐合作網站授權轉載。文章觀點僅代表作者本人,不代表電子發燒友網立場。文章及其配圖僅供工程師學習之用,如有內容侵權或者其他違規問題,請聯系本站處理。 舉報投訴
  • 函數
    +關注

    關注

    3

    文章

    4346

    瀏覽量

    62982
  • GitHub
    +關注

    關注

    3

    文章

    473

    瀏覽量

    16580
  • tensorflow
    +關注

    關注

    13

    文章

    329

    瀏覽量

    60633

原文標題:【收藏】簡單易用 TensorFlow 代碼集,GAN通用框架、函數

文章出處:【微信號:AI_era,微信公眾號:新智元】歡迎添加關注!文章轉載請注明出處。

收藏 人收藏

    評論

    相關推薦

    如何使用tensorflow快速搭建起深度學習項目

    我們繼續以 NG 課題組提供的 sign 手勢數據集為例,學習如何通過Tensorflow快速搭建起深度學習項目。數據集標簽共有零到五總共 6 類標簽,示例如下
    的頭像 發表于 10-25 08:57 ?7742次閱讀

    干貨 | TensorFlow的55經典案例

    ://yann.lecun.com/exdb/mnist/第二步:為TF新手準備的各個類型的案例、模型和數據集初步了解:TFLearn TensorFlow接下來的示例來自TFLearn,這是
    發表于 10-09 11:28

    TensorFlow是什么

    來發現和理解瀕臨滅絕的海牛。位日本農民運用 TensorFlow 開發了應用程序,使用大小和形狀等物理特性對黃瓜進行分類。使用 Tensor
    發表于 07-22 10:14

    TensorFlow的特點和基本的操作方式

    Tensorflow是Google開源的深度學習框架,來自于Google Brain研究項目,在Google第代分布式機器學習框架DistBelief的基礎上發展起來。Tensorflow
    發表于 11-23 09:56

    The VHDL Cookbook

    The VHDL Cookbook 好東西哦。網上搜集,希望對你有用。
    發表于 03-25 14:37 ?19次下載

    github入門到上傳本地項目步驟

    GitHub可以托管各種git庫,并提供web界面,但與其它像 SourceForge或Google Code這樣的服務不同,GitHub的獨特賣點在于從另外
    發表于 11-29 16:51 ?2240次閱讀

    github使用教程_github菜鳥教程

    GitHub 擁有非常鼓勵合作的社區氛圍。這方面源于 GitHub 的付費模式:私有項目
    發表于 11-29 17:22 ?1.5w次閱讀
    <b class='flag-5'>github</b>使用教程_<b class='flag-5'>github</b>菜鳥教程

    提出快速啟動自己的 TensorFlow 項目模板

    簡潔而精密的結構對于深度學習項目來說是必不可少的,在經過多次練習和 TensorFlow 項目開發之后,本文作者提出了結合簡便性、優化文
    的頭像 發表于 02-07 11:47 ?3211次閱讀
    提出<b class='flag-5'>一</b><b class='flag-5'>個</b>快速啟動自己的 <b class='flag-5'>TensorFlow</b> <b class='flag-5'>項目</b>模板

    總結Tensorflow純干貨學習資源,分為教程、視頻和項目三大板塊

    基于Facebook中FastText的簡單嵌入式文本分類器:https://github.com/apcode/tensorflow_fasttext。該項目是源于Facebook中
    的頭像 發表于 04-16 11:39 ?1.1w次閱讀

    人工智能涼了? GitHub年度報告揭示真相

    去年GitHub的報告中,人工智能非常火。今年情況如何?在下面的圖表中,可以看到: Tensorflow在最熱開源項目中排第三;在增長最快的項目中Pytorch排名第二,
    的頭像 發表于 10-23 10:16 ?3557次閱讀

    總結GitHub熱門開源項目

    項目的熱門程度,較為直觀的判斷方式就是它的Stars增長速度,排行第的flutter依然是Google家的,Flutter 是在2018年的2月份才推出第
    的頭像 發表于 01-18 14:15 ?2976次閱讀

    GitHub年度報告:Python首次擊敗Java

    作為 GitHub 上最受歡迎的項目TensorFlow 已經建立了龐大的軟件社區。去
    的頭像 發表于 11-22 15:14 ?2489次閱讀

    TensorFlow Community Spotlight獲獎項目

    Spotlight 獲獎者,她用 TensorFlow 開發出款追蹤坐姿的工具,當使用者坐姿不正確的情況下屏幕會變模糊 在這四
    的頭像 發表于 11-26 09:43 ?1872次閱讀

    上傳本地項目代碼到github

    GitHub面向開源及私有軟件項目的托管平臺,因為只支持git 作為唯的版本庫格式進行托管,故名
    的頭像 發表于 11-14 16:45 ?1109次閱讀
    上傳本地<b class='flag-5'>項目</b>代碼到<b class='flag-5'>github</b>

    如何使用Github高效率的查找項目

    GitHub各位應該都很熟悉了,全球最大的開源社區,也是全球最大的同性交友網站~~,但是大部分同學使用GitHub應該就是通過別人的開源鏈接,點進去下載對應的項目,而真正使用Github
    的頭像 發表于 09-24 14:43 ?746次閱讀
    如何使用<b class='flag-5'>Github</b>高效率的查找<b class='flag-5'>項目</b>
    主站蜘蛛池模板: 免费看一级片 | 特级全黄一级毛片视频 | 亚洲免费视频一区二区三区 | 欧美日韩一日韩一线不卡 | 黑色丝袜在丝袜福利国产 | 亚洲男人的天堂久久香蕉 | 中文免费观看视频网站 | 性欧美大战久久久久久久 | 国外精品视频在线观看免费 | 美女毛片免费 | 久久久久四虎国产精品 | 国产三级在线观看播放 | 日本jlzz| 亚洲人成电影在线播放 | 久久狠狠躁免费观看 | 久久久噜噜噜久久中文字幕色伊伊 | 亚洲精品久 | 久久久黄色大片 | 欧美猛交lxxxxxxxxx| 全黄性色大片 | 久久香蕉国产线看观看亚洲片 | 嫩草影院地址一地址二 | 免费高清在线视频色yeye | 手机看片1024国产基地 | 黄免费视频 | 激情啪啪网站 | 一本大道高清在线视频 视频 | 一区不卡 | 成人午夜精品久久久久久久小说 | 午夜小视频免费 | 亚洲伦理一区 | 久久国产精品永久免费网站 | 精品欧美一区二区三区在线观看 | 在线www 天堂网在线 | 日韩毛片免费线上观看 | 一区二区中文字幕亚洲精品 | jizjizjizjiz日本护士出水 | 国产在线播放你懂的 | 美女视频黄a视频美女大全 美女视频一区二区 | 偷偷狠狠的日日日日 | 日本5级床片全免费 |