[圖片上傳失敗...(image-ee44b2-1619413842353)]
](https://upload-images.jianshu.io/upload_images/16949777-c3860d701efbec2e.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
content_loss += torch.mean((f1 - f2) ** 2)
為了解決L1 loss在0點(diǎn)處不能求導(dǎo)以及L2 loss對(duì)離群點(diǎn)比較敏感的問(wèn)題宋下,提出了huber loss融合了L1政模、L2 loss的優(yōu)點(diǎn)
BCE loss是二元交叉熵?fù)p失笋熬,其實(shí)是二分類(lèi)交叉熵?fù)p失十偶,可以用在前背景分割菩鲜、語(yǔ)義分割的網(wǎng)絡(luò)訓(xùn)練當(dāng)中
loss_fn = nn.BCELoss()
感知損失,就是把預(yù)訓(xùn)練好的特征提取器相當(dāng)于人的眼睛惦积,要求生成的圖像和真實(shí)圖像經(jīng)過(guò)預(yù)訓(xùn)練好的模型提取得到的特征盡可能相似接校。在圖像生成里面,感知損失可以讓圖片生成地更加逼真一些
什么是自編碼器狮崩,自編碼器及其應(yīng)用詳解 (biancheng.net)
關(guān)于自編碼器的核心點(diǎn)理解zhuhongde的博客-CSDN博客自編碼器
def cosine_similarities(vector_1, vectors_all):
"""Compute cosine similarities between one vector and a set of other vectors.
Parameters
----------
vector_1 : numpy.ndarray
Vector from which similarities are to be computed, expected shape (dim,).
vectors_all : numpy.ndarray
For each row in vectors_all, distance from vector_1 is computed, expected shape (num_vectors, dim).
Returns
-------
numpy.ndarray
Contains cosine distance between `vector_1` and each row in `vectors_all`, shape (num_vectors,).
"""
norm = np.linalg.norm(vector_1)
all_norms = np.linalg.norm(vectors_all, axis=1)
dot_products = dot(vectors_all, vector_1)
similarities = dot_products / (norm * all_norms)
return similarities