TensorFlow 서브 라이브러리 개요
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
tensorflow_hub
라이브러리를 사용하면 최소한의 코드만 사용하여 TensorFlow 프로그램에서 학습된 모델을 다운로드하고 재사용할 수 있습니다. 학습된 모델을 로드하는 주된 방법은 hub.KerasLayer
API를 이용하는 것입니다.
import tensorflow_hub as hub
embed = hub.KerasLayer("https://tfhub.dev/google/nnlm-en-dim128/2")
embeddings = embed(["A long sentence.", "single-word", "http://example.com"])
print(embeddings.shape, embeddings.dtype)
다운로드를 위한 캐시 위치 설정하기
기본적으로 tensorflow_hub
는 시스템 전체의 임시 디렉터리를 사용하여 다운로드 및 압축되지 않은 모델을 캐시합니다. 더 영구적인 다른 위치를 사용하는 옵션은 캐싱을 참조하세요.
API 안정성
파격적인 변경 사항은 없길 바라지만, 이 프로젝트는 아직 개발 중이며 안정적인 API 또는 모델 형식을 보장하지 않습니다.
공평
모든 머신러닝에서와 마찬가지로, 공정성은 중요한 고려 사항입니다. 많은 사전 훈련된 모델이 대규모 데이터세트에서 훈련됩니다. 모델을 재사용할 때 모델이 학습한 데이터(및 기존 바이어스가 있는지 여부)와 데이터세트가 모델 사용에 어떤 영향을 미칠 수 있는지를 염두에 두는 것이 중요합니다.
보안
모델은 임의의 TensorFlow 그래프를 포함하기 때문에 프로그램으로 생각할 수 있습니다. TensorFlow를 안전하게 사용하기에서는 신뢰할 수 없는 소스에서 모델을 참조할 때 보안에 미치는 영향을 설명합니다.
다음 단계
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2024-02-12(UTC)
[null,null,["최종 업데이트: 2024-02-12(UTC)"],[],[],null,["# TensorFlow Hub Library Overview\n\n\u003cbr /\u003e\n\nThe [`tensorflow_hub`](https://github.com/tensorflow/hub) library lets you\ndownload and reuse trained models in your TensorFlow program with a minimum\namount of code. The main way to load a trained model is using the\n[`hub.KerasLayer`](https://www.tensorflow.org/hub/api_docs/python/hub/KerasLayer) API. \n\n import tensorflow_hub as hub\n\n embed = hub.KerasLayer(\"https://tfhub.dev/google/nnlm-en-dim128/2\")\n embeddings = embed([\"A long sentence.\", \"single-word\", \"http://example.com\"])\n print(embeddings.shape, embeddings.dtype)\n\n**Note:** This documentation uses TFhub.dev URL handles in examples. See more\ninformation regarding other valid handle types [here](/hub/tf2_saved_model#model_handles).\n\nSetting the cache location for downloads.\n-----------------------------------------\n\nBy default, `tensorflow_hub` uses a system-wide, temporary directory to cache\ndownloaded and uncompressed models. See [Caching](/hub/caching) for options to use\nother, possibly more persistent locations.\n\nAPI stability\n-------------\n\nAlthough we hope to prevent breaking changes, this project is still under active\ndevelopment and is not yet guaranteed to have a stable API or model format.\n\nFairness\n--------\n\nAs in all of machine learning, [fairness](http://ml-fairness.com) is an\n[important](https://research.googleblog.com/2016/10/equality-of-opportunity-in-machine.html)\nconsideration. Many pre-trained models are trained on large datasets. When\nreusing any model, it's important to be mindful of what data the model was\ntrained on (and whether there are any existing biases there), and how these\nmight impact your use of it.\n\nSecurity\n--------\n\nSince they contain arbitrary TensorFlow graphs, models can be thought of as\nprograms.\n[Using TensorFlow Securely](https://github.com/tensorflow/tensorflow/blob/master/SECURITY.md)\ndescribes the security implications of referencing a model from an untrusted\nsource.\n\nNext Steps\n----------\n\n- [Use the library](/hub/tf2_saved_model)\n- [Reusable SavedModels](/hub/reusable_saved_models)"]]