91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

這是基于Pytorch的圖片風格遷移教程源碼,對其進行了逐句對照解析以便于理解。 詳情請搜索博文:【Pytorch代碼】神經風格遷移Pytorch教程代碼 逐句解析

資源截圖

代碼片段和文件信息


#?coding:?utf-8

#?In[?]:


【Paper翻譯】A?Neural?Algorithm?Artistic?style:https://blog.csdn.net/sinat_33761963/article/details/53521292


#?In[27]:


get_ipython().run_line_magic(‘matplotlib‘?‘inline??????#?Python中定義的魔法函數,使得matplotlib中繪制的圖像都顯示在Notebook頁面內,而不是新彈出窗口‘)
???????????????????????#?這是IPython的命令函數,智能在Jupyter?Notebook中使用,在別的IDE中會出錯


#?
#?Neural?Transfer?Using?PyTorch
#?=============================
#?
#?
#?**Author**:?‘Alexis?Jacq?‘_
#??
#?**Edited?by**:?‘Winston?Herring?‘_
#?
#?Introduction
#?------------
#?
#?This?tutorial?explains?how?to?implement?the?‘Neural-style?algorithm?‘__
#?developed?by?Leon?A.?Gatys?Alexander?S.?Ecker?and?Matthias?Bethge.
#?Neural-style?or?Neural-Transfer?allows?you?to?take?an?image?and
#?reproduce?it?with?a?new?artistic?style.?The?algorithm?takes?three?images
#?an?input?image?a?content-image?and?a?style-image?and?changes?the?input?
#?to?resemble?the?content?of?the?content-image?and?the?artistic?style?of?the?style-image.
#?
#??
#?..?figure::?/_static/img/neural-style/neuralstyle.png
#????:alt:?content1
#?
#?

#?基于Pytorch的神經網絡風格遷移
#?
#?本教程展示如何實現由Leon?A.?Gatys、Alexander?S.?Ecker和Matthias?Bethge開發的神經風格算法__。神經風格遷移可以讓你用一種新的藝術風格來重構圖像。該算法用一個風格圖像,一個內容圖像,使得模型通過改變輸入來模仿內容圖像的內容和樣式圖像的藝術風格。

#?Underlying?Principle
#?--------------------
#?
#?The?principle?is?simple:?we?define?two?distances?one?for?the?content
#?($D_C$)?and?one?for?the?style?($D_S$).?$D_C$?measures?how?different?the?content
#?is?between?two?images?while?$D_S$?measures?how?different?the?style?is
#?between?two?images.?Then?we?take?a?third?image?the?input?and
#?transform?it?to?minimize?both?its?content-distance?with?the
#?content-image?and?its?style-distance?with?the?style-image.?Now?we?can
#?import?the?necessary?packages?and?begin?the?neural?transfer.
#?
#?Importing?Packages?and?Selecting?a?Device
#?-----------------------------------------
#?Below?is?a??list?of?the?packages?needed?to?implement?the?neural?transfer.
#?
#?-??‘‘torch‘‘?‘‘torch.nn‘‘?‘‘numpy‘‘?(indispensables?packages?for
#????neural?networks?with?PyTorch)
#?-??‘‘torch.optim‘‘?(efficient?gradient?descents)
#?-??‘‘PIL‘‘?‘‘PIL.Image‘‘?‘‘matplotlib.pyplot‘‘?(load?and?display
#????images)
#?-??‘‘torchvision.transforms‘‘?(transform?PIL?images?into?tensors)
#?-??‘‘torchvision.models‘‘?(train?or?load?pre-trained?models)
#?-??‘‘copy‘‘?(to?deep?copy?the?models;?system?package)
#?
#?

#?基本原理
#?首先定義兩個距離:一個內容距離(

評論

共有 條評論