TensorFlow Similarity 学习笔记1

TensorFlow Similarity 学习笔记1

2021SC@SDUSC

  • Introduction
    TensorFlow Similarity是TensorFlow为相似学习或称为度量学习/对比学习设计的库。其提供度量学习的算法以及所有为研究训练,评估的必须组件。
    利用TensorFlow Similarity我们可以训练和服务能在大规模语料库中找相似物件(如图像)的模型。例如,如下图所示,你可以通过Oxford IIIT Pet Dataset的一些训练集合,训练一个相似模型来找到相似长相的猫和狗。
    TensorFlow Similarity 学习笔记1_第1张图片

度量学习和传统分类器的目标不同。模型学习利用监督或自监督方法将相似样本的距离最小化同时最大化非相似样本的距离。TensorFlow Similarity提供必要的losses, metrics, samplers, visualizers, 和indexing sub-system来使这个过程更便捷。
目前,TensorFlow Similarity支持监督训练。未来的版本,它将会支持版监督和自监督训练。

  • Things to try
import numpy as np
from tabulate import tabulate
from matplotlib import pyplot as plt
import tensorflow as tf
from tensorflow.keras import layers
from tensorflow.keras.models import load_model
from tensorflow.keras.optimizers import Adam
import tensorflow_similarity as tfsim
from tensorflow_similarity.utils import tf_cap_memory
from tensorflow_similarity.layers import MetricEmbedding
from tensorflow_similarity.losses import MultiSimilarityLoss
from tensorflow_similarity.models import SimilarityModel
from tensorflow_similarity.samplers import MultiShotMemorySampler
from tensorflow_similarity.samplers import select_examples
from tensorflow_similarity.visualization import viz_neigbors_imgs
from tensorflow_similarity.visualization import confusion_matrix

tfsim.utils.tf_cap_memory()

print('TensorFlow:', tf.__version__)
print('Tensorflow Similarity', tfsim.__version__)

/Users/xu/opt/anaconda3/envs/tensor/bin/python /Users/xu/Desktop/TFS/HelloWorld.py
2021-09-28 18:25:21.369429: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
Your CPU supports instructions that this binary was not compiled to use: AVX2
For maximum performance, you can install NMSLIB from sources
pip install --no-binary :all: nmslib
TensorFlow: 2.6.0
Tensorflow Similarity 0.13.44

分工

初步分工,负责源码中models、losses、keras模块代码分析学习。

你可能感兴趣的:(tensorflow,深度学习,python)