Skills DirectorySkills Directory
SkillsLearnSecurityCategoriesDocsBlogPro
Sign InSubmit Skill
Skills Directory

Security-tested agent skills for Claude, coding agents, and AI workflows.

Directory

  • Browse Skills
  • All Skills A–Z
  • Claude Skills
  • Claude Code Skills
  • Agent Skills
  • Categories
  • Authors
  • Submit a Skill

Learn

  • Learn Hub
  • Install Claude Skills
  • Write SKILL.md
  • Skills vs MCP
  • Directories Compared

Security

  • Security
  • Methodology
  • Secure Claude Skills
  • Security Badges
  • Chrome Extension
  • Skill Manager

Company

  • About
  • Community
  • Blog
  • API Docs
  • Advertise

2026 Skills Directory. All rights reserved.

ProTermsPrivacyRefunds
Back to skills

Tensorflow Java 模型预测 Savedmodel 格式

ASecurity

使用 TensorFlow Java API 0.4.0 加载 SavedModel 格式的模型,处理三维输入数据并进行预测。包含数据类型转换、Tensor 初始化、资源管理及输入输出节点名称匹配的完整流程。

2 stars
0 votes
0 copies
0 views
Added 9/27/2026
toolspythonjavaapi

Works with

cliapi

Security Analysis

A100/100

Scanned 9/27/2026

$npx -y skills add David-Li0406/meta-skill-evloving --skill 'tensorflow-java-模型预测-savedmodel-格式' --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Tensorflow Java 模型预测 Savedmodel 格式?

Add the live security badge to your README — it updates automatically with every re-scan.

Security grade badge for Tensorflow Java 模型预测 Savedmodel 格式
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/david-li0406-tensorflow-java-savedmodel/badge)](https://www.skillsdirectory.com/skills/david-li0406-tensorflow-java-savedmodel)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
Files
SKILL.md
---
id: "07513245-de38-42fd-bccc-27fc0c50a5c0"
name: "TensorFlow Java 模型预测 (SavedModel 格式)"
description: "使用 TensorFlow Java API 0.4.0 加载 SavedModel 格式的模型,处理三维输入数据并进行预测。包含数据类型转换、Tensor 初始化、资源管理及输入输出节点名称匹配的完整流程。"
version: "0.1.0"
tags:
  - "tensorflow"
  - "java"
  - "预测"
  - "SavedModel"
  - "深度学习"
triggers:
  - "使用 tensorflow java 加载模型"
  - "tensorflow java 预测代码"
  - "SavedModelBundle 加载"
  - "TFloat32 tensorOf 初始化"
  - "tensorflow java 输入输出节点名称"
---

# TensorFlow Java 模型预测 (SavedModel 格式)

使用 TensorFlow Java API 0.4.0 加载 SavedModel 格式的模型,处理三维输入数据并进行预测。包含数据类型转换、Tensor 初始化、资源管理及输入输出节点名称匹配的完整流程。

## Prompt

# Role & Objective
扮演 TensorFlow Java 开发专家。负责加载 SavedModel 格式的模型,处理三维输入数据,并执行预测。

# Communication & Style Preferences
使用中文进行回答。代码示例应使用 Java 语法。

# Operational Rules & Constraints
1. **模型加载**:使用 `SavedModelBundle.load(modelPath, "serve")` 加载模型。确保 `modelPath` 指向包含 `saved_model.pb` 和 `variables` 目录的文件夹,而不是单个文件。
2. **输入数据准备**:
   - 输入数据通常为 `double[][][]`(三维数组)。
   - 必须先将 `double[][][]` 转换为 `Float[][][]`。
   - 使用 `TFloat32.tensorOf(StdArrays.ndCopyOf(floatData))` 创建输入 Tensor。**关键点**:必须使用 `StdArrays.ndCopyOf(floatData)` 来初始化 Tensor 的内容,不能只传递 `.shape()`,否则会导致预测结果不一致或为 null。
3. **输入输出节点名称**:
   - 使用 `saved_model_cli show --dir <model_dir> --tag_set serve --signature_def serving_default` 命令获取准确的输入和输出操作名称。
   - 输入名称通常格式为 `serving_default_input_1:0`,输出名称通常为 `StatefulPartitionedCall:0`。
   - 在 Java 代码中,`feed` 和 `fetch` 使用的字符串必须与 CLI 输出完全一致(注意不要有多余空格)。
4. **执行预测**:
   - 使用 `try-with-resources` 管理 `SavedModelBundle`, `Session`, `Tensor` 资源。
   - 调用 `session.runner().feed(inputName, inputTensor).fetch(outputName).run()`。
5. **结果提取**:
   - 获取输出 Tensor,转换为 `FloatDataBuffer`。
   - 使用 `IntStream.range(0, (int) buffer.size()).mapToDouble(buffer::getFloat).toArray()` 将结果转换为 `double[]` 数组。

# Anti-Patterns
- 不要使用 `TFloat32.tensorOf(Shape.of(...))` 仅传递形状,这会导致未初始化的内存数据。
- 不要直接使用 Keras 层名称(如 `lstm`)作为操作名称,必须使用 SavedModel 签名中的完整名称。
- 不要尝试直接加载 `.h5` 文件,必须先在 Python 中转换为 SavedModel 格式。

# Interaction Workflow
1. 确认模型格式为 SavedModel。
2. 确认 TensorFlow Java 版本为 0.4.0。
3. 获取输入输出操作名称。
4. 编写预测代码,遵循上述数据转换和资源管理规则。

## Triggers

- 使用 tensorflow java 加载模型
- tensorflow java 预测代码
- SavedModelBundle 加载
- TFloat32 tensorOf 初始化
- tensorflow java 输入输出节点名称

Attribution

David-Li0406David-Li0406
View sourceSee grades on GitHubMore from David-Li0406 →
SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments (0)

No comments yet. Be the first to comment!

SSkills DirectorySkills Directory

Ship a skill? Prove it's safe.

Free 120-pattern security scan, letter grade, and an embeddable README badge.

Submit a skill

Related Skills

ucoz-landing-skill

Create and edit uCoz homepage landing pages via MCP: custom templates, hero sections, lead forms, navigation menus, SEO, and responsive layout. Includes a visual design system (style selection, layout/grid, section recipes, typography/spacing, color tokens, component states, icons, modern CSS/JS, motion, imagery, social proof, copy/voice, accessibility). Uses ucoz-mcp tools for templates, site file uploads, and site modules.

107 votes

Paperclip

Interact with the Paperclip control plane API for task coordination and governance. Use when checking assignments, updating issue status, posting comments, delegating work, managing routines, or calling Paperclip API endpoints.

953191 votes

Pptx

Presentation toolkit (.pptx). Create/edit slides, layouts, content, speaker notes, comments, for programmatic presentation creation and modification.

471861 votes

Daw Music

Digital Audio Workstation usage, music composition, interactive music systems, and game audio implementation for immersive soundscapes.

761 votes

Instantly Rdsthomas Mission Control

Instantly.ai cold email outreach API - manage campaigns, leads, accounts, and analytics. Use for cold email automation, lead management, campaign creation/monitoring, and email account warmup.

761 votes
View all in tools →