keras-ops

Enforce keras.ops tensor operations for multi-backend BayesFlow extensions.

Updated Mar 5, 2026
One-click install
npx skills add https://github.com/matthiaskloft/claude-skills --skill keras-ops
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: keras-ops
Source: https://github.com/matthiaskloft/claude-skills/tree/main/bayesflow/skills/keras-ops
Command: npx skills add https://github.com/matthiaskloft/claude-skills --skill keras-ops

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill ensures that all tensor operations within BayesFlow extensions are compatible across different backends (PyTorch, JAX, TensorFlow) by enforcing the use of keras.ops.*.

Core Features & Use Cases

  • Backend Agnosticism: Guarantees code runs seamlessly on PyTorch, JAX, or TensorFlow.
  • Standardized Operations: Provides a consistent interface for common tensor manipulations like sum, mean, exp, reshape, and more.
  • Use Case: When developing a custom Keras layer for a BayesFlow model, use keras.ops.sum instead of torch.sum to ensure your layer works regardless of the chosen backend.

Quick Start

Use the keras-ops skill to perform a sum operation on a tensor using keras.ops.sum.

Frequently Asked Questions about keras-ops

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write backend-agnostic tensor math operations for BayesFlow extensions?

Use the keras.ops module for all tensor math operations like sum, mean, and reshape. This ensures custom Keras layers and loss functions run seamlessly across PyTorch, JAX, and TensorFlow.

What is the best way to ensure Keras custom layers work across JAX, PyTorch, and TensorFlow?

Adhere strictly to keras.ops.* for all tensor computations. Avoid native framework functions like torch.sum to allow seamless execution across JAX, PyTorch, and TensorFlow.

Can I use native PyTorch or JAX functions for tensor manipulations in BayesFlow models?

Do not use native PyTorch or JAX functions in BayesFlow extensions. You must use keras.ops.* for tensor manipulations to guarantee your code remains compatible regardless of the chosen backend.

When do I need to use keras.ops for tensor computations?

Use keras.ops for tensor computations when writing loss functions, custom Keras layers, network forward passes, and approximator overrides in BayesFlow. This guarantees standardized operations across all supported backends.

Why does my custom Keras layer fail when switching from TensorFlow to PyTorch?

Your custom Keras layer fails across backends if it uses framework-specific tensor math instead of keras.ops. Enforcing keras.ops.* standardizes operations and guarantees multi-backend compatibility for BayesFlow extensions.