امضاهای رایج برای متن
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این صفحه امضاهای رایجی را توضیح میدهد که باید توسط ماژولها در قالب TF1 Hub برای کارهایی که ورودیهای متن را میپذیرند، پیادهسازی کنند. (برای فرمت TF2 SavedModel ، به API مشابه SavedModel مراجعه کنید.)
وکتور ویژگی متن
یک ماژول بردار ویژگی متن، یک نمایش برداری متراکم از ویژگی های متن ایجاد می کند. دستهای از رشتههای شکل [batch_size]
را میپذیرد و آنها را به یک تانسور float32
از شکل [batch_size, N]
نگاشت میکند. اغلب به این کار تعبیه متن در بعد N
می گویند.
استفاده اساسی
embed = hub.Module("path/to/module")
representations = embed([
"A long sentence.",
"single-word",
"http://example.com"])
استفاده از ستون ویژگی
feature_columns = [
hub.text_embedding_column("comment", "path/to/module", trainable=False),
]
input_fn = tf.estimator.inputs.numpy_input_fn(features, labels, shuffle=True)
estimator = tf.estimator.DNNClassifier(hidden_units, feature_columns)
estimator.train(input_fn, max_steps=100)
یادداشت ها
ماژول ها در حوزه ها و/یا وظایف مختلف از قبل آموزش داده شده اند و بنابراین هر ماژول بردار ویژگی متنی برای مشکل شما مناسب نیست. به عنوان مثال: برخی از ماژول ها می توانستند روی یک زبان آموزش داده شوند.
این رابط اجازه تنظیم دقیق نمایش متن در TPU ها را نمی دهد، زیرا به ماژول نیاز دارد که هم پردازش رشته و هم متغیرهای قابل آموزش را به طور همزمان نمونه سازی کند.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-07-25 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Common Signatures for Text\n\n\u003cbr /\u003e\n\nThis page describes common signatures that should be implemented by modules in\nthe [TF1 Hub format](../tf1_hub_module) for tasks that accept text inputs.\n(For the [TF2 SavedModel format](../tf2_saved_model), see the analogous\n[SavedModel API](../common_saved_model_apis/text).)\n\nText feature vector\n-------------------\n\nA **text feature vector** module creates a dense vector representation\nfrom text features.\nIt accepts a batch of strings of shape `[batch_size]` and maps them to\na `float32` tensor of shape `[batch_size, N]`. This is often called\n**text embedding** in dimension `N`.\n\n### Basic usage\n\n embed = hub.Module(\"path/to/module\")\n representations = embed([\n \"A long sentence.\",\n \"single-word\",\n \"http://example.com\"])\n\n### Feature column usage\n\n feature_columns = [\n hub.text_embedding_column(\"comment\", \"path/to/module\", trainable=False),\n ]\n input_fn = tf.estimator.inputs.numpy_input_fn(features, labels, shuffle=True)\n estimator = tf.estimator.DNNClassifier(hidden_units, feature_columns)\n estimator.train(input_fn, max_steps=100)\n\nNotes\n-----\n\nModules have been pre-trained on different domains and/or tasks,\nand therefore not every text feature vector module would be suitable for\nyour problem. E.g.: some modules could have been trained on a single language.\n\nThis interface does not allow fine-tuning of the text representation on TPUs,\nbecause it requires the module to instantiate both string processing and the\ntrainable variables at the same time."]]