欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

keras提供了三種定義模型方式分別是什么-創(chuàng)新互聯(lián)

創(chuàng)新互聯(lián)www.cdcxhl.cn八線(xiàn)動(dòng)態(tài)BGP香港云服務(wù)器提供商,新人活動(dòng)買(mǎi)多久送多久,劃算不套路!

企業(yè)建站必須是能夠以充分展現(xiàn)企業(yè)形象為主要目的,是企業(yè)文化與產(chǎn)品對(duì)外擴(kuò)展宣傳的重要窗口,一個(gè)合格的網(wǎng)站不僅僅能為公司帶來(lái)巨大的互聯(lián)網(wǎng)上的收集和信息發(fā)布平臺(tái),成都創(chuàng)新互聯(lián)公司面向各種領(lǐng)域:成都陽(yáng)光房成都網(wǎng)站設(shè)計(jì)全網(wǎng)營(yíng)銷(xiāo)推廣解決方案、網(wǎng)站設(shè)計(jì)等建站排名服務(wù)。

這篇文章主要介紹keras提供了三種定義模型方式分別是什么,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

前言

一、keras提供了三種定義模型的方式

1. 序列式(Sequential) API

序貫(sequential)API允許你為大多數(shù)問(wèn)題逐層堆疊創(chuàng)建模型。雖然說(shuō)對(duì)很多的應(yīng)用來(lái)說(shuō),這樣的一個(gè)手法很簡(jiǎn)單也解決了很多深度學(xué)習(xí)網(wǎng)絡(luò)結(jié)構(gòu)的構(gòu)建,但是它也有限制-它不允許你創(chuàng)建模型有共享層或有多個(gè)輸入或輸出的網(wǎng)絡(luò)。

2. 函數(shù)式(Functional) API

Keras函數(shù)式(functional)API為構(gòu)建網(wǎng)絡(luò)模型提供了更為靈活的方式。

它允許你定義多個(gè)輸入或輸出模型以及共享圖層的模型。除此之外,它允許你定義動(dòng)態(tài)(ad-hoc)的非周期性(acyclic)網(wǎng)絡(luò)圖。

模型是通過(guò)創(chuàng)建層的實(shí)例(layer instances)并將它們直接相互連接成對(duì)來(lái)定義的,然后定義一個(gè)模型(model)來(lái)指定那些層是要作為這個(gè)模型的輸入和輸出。

3.子類(lèi)(Subclassing) API

補(bǔ)充知識(shí):keras pytorch 構(gòu)建模型對(duì)比

使用CIFAR10數(shù)據(jù)集,用三種框架構(gòu)建Residual_Network作為例子,比較框架間的異同。

數(shù)據(jù)集格式

pytorch的數(shù)據(jù)集格式

import torch
import torch.nn as nn
import torchvision

# Download and construct CIFAR-10 dataset.
train_dataset = torchvision.datasets.CIFAR10(root='../../data/',
                       train=True, 
                       download=True)

# Fetch one data pair (read data from disk).
image, label = train_dataset[0]
print (image.size()) # torch.Size([3, 32, 32])
print (label) # 6
print (train_dataset.data.shape) # (50000, 32, 32, 3)
# type(train_dataset.targets)==list
print (len(train_dataset.targets)) # 50000

# Data loader (this provides queues and threads in a very simple way).
train_loader = torch.utils.data.DataLoader(dataset=train_dataset,
                      batch_size=64, 
                      shuffle=True)
"""
# 演示DataLoader返回的數(shù)據(jù)結(jié)構(gòu)
# When iteration starts, queue and thread start to load data from files.
data_iter = iter(train_loader)

# Mini-batch images and labels.
images, labels = data_iter.next()
print(images.shape) # torch.Size([100, 3, 32, 32])
print(labels.shape) 
# torch.Size([100]) 可見(jiàn)經(jīng)過(guò)DataLoader后,labels由list變成了pytorch內(nèi)置的tensor格式
"""
# 一般使用的話(huà)是下面這種
# Actual usage of the data loader is as below.
for images, labels in train_loader:
  # Training code should be written here.
  pass

網(wǎng)站標(biāo)題:keras提供了三種定義模型方式分別是什么-創(chuàng)新互聯(lián)
轉(zhuǎn)載源于:http://www.chinadenli.net/article8/dgioip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供虛擬主機(jī)網(wǎng)站改版域名注冊(cè)網(wǎng)站策劃小程序開(kāi)發(fā)App設(shè)計(jì)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)