TensorFlow学习笔记

本文介绍了TensorFlow中Estimator API的功能与使用方法,并详细探讨了TensorFlow Hub提供的预训练模型资源,包括文本分类任务中使用的通用句子编码器等。通过实例展示了如何利用这些模块进行迁移学习。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Estimater

Estimator:代表一个完整的模型。Estimator API 提供一些方法来训练模型、判断模型的准确率并生成预测。

TF-Hub

TensorFlow Hub is a library to foster the publication, discovery, and consumption of reusable parts of machine learning models. A module is a self-contained piece of a TensorFlow graph, along with its weights and assets, that can be reused across different tasks in a process known as transfer learning.

1. text classification

sentence embedding models: Universal sentence encoder https://www.tensorflow.org/hub/modules/google/universal-sentence-encoder/1

  • Transformer
  • DAN(Deep average network)

Example

import tensorflow as tf
import tensorflow_hub as hub

with tf.Graph().as_default():
  embed = hub.Module("https://tfhub.dev/google/nnlm-en-dim128-with-normalization/1")
  embeddings = embed(["A long sentence.", "single-word", "http://example.com"])

  with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    sess.run(tf.tables_initializer())

    print(sess.run(embeddings))
2. image retraining
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值