or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

activations.mdapplications.mddata-utils.mdindex.mdinitializers.mdlayers.mdmodels.mdoperations.mdrandom.mdregularizers.mdsaving.mdtraining.md
tile.json

tessl/pypi-keras

Multi-backend deep learning framework that provides a unified, high-level API for building and training neural networks across JAX, TensorFlow, PyTorch, and OpenVINO backends.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/keras@3.11.x

To install, run

npx @tessl/cli install tessl/pypi-keras@3.11.0

index.mddocs/

Keras

Keras is a multi-backend deep learning framework that provides a unified, high-level API for building and training neural networks across JAX, TensorFlow, PyTorch, and OpenVINO backends. It enables accelerated model development through its intuitive interface while offering state-of-the-art performance with backend-specific optimizations.

Package Information

  • Package Name: keras
  • Language: Python
  • Installation: pip install keras
  • Documentation: https://keras.io/

Core Imports

import keras

For specific functionality:

from keras import layers, models, optimizers, losses, metrics
from keras.applications import ResNet50, VGG16, MobileNet
from keras.datasets import mnist, cifar10

Basic Usage

import keras
from keras import layers

# Create a simple sequential model
model = keras.Sequential([
    layers.Dense(128, activation='relu', input_shape=(784,)),
    layers.Dropout(0.2),
    layers.Dense(10, activation='softmax')
])

# Compile the model
model.compile(
    optimizer='adam',
    loss='sparse_categorical_crossentropy',
    metrics=['accuracy']
)

# Train the model
# model.fit(x_train, y_train, epochs=5, validation_data=(x_test, y_test))

Architecture

Keras follows a modular architecture with these core components:

  • Models: Containers that organize layers (Sequential, Functional API, Model subclassing)
  • Layers: Building blocks for neural networks (Dense, Conv2D, LSTM, etc.)
  • Optimizers: Algorithms for training models (Adam, SGD, RMSprop, etc.)
  • Losses: Functions to measure model performance during training
  • Metrics: Functions to monitor training and testing
  • Callbacks: Utilities to customize training behavior
  • Backend: Abstraction layer supporting JAX, TensorFlow, PyTorch, and OpenVINO

Capabilities

Models and Architecture

Core model types and architecture patterns for building neural networks, including Sequential models, Functional API, and Model subclassing approaches.

class Model:
    def __init__(self, inputs=None, outputs=None, name=None): ...
    def compile(self, optimizer='rmsprop', loss=None, metrics=None, **kwargs): ...
    def fit(self, x=None, y=None, batch_size=None, epochs=1, **kwargs): ...
    def predict(self, x, batch_size=None, **kwargs): ...

class Sequential(Model):
    def __init__(self, layers=None, name=None): ...
    def add(self, layer): ...

def Input(shape=None, batch_size=None, name=None, dtype=None, **kwargs): ...

Models and Architecture

Layers and Building Blocks

Comprehensive layer types for building neural networks, including core layers, convolutional layers, recurrent layers, attention mechanisms, normalization, pooling, and preprocessing layers.

class Layer:
    def __init__(self, **kwargs): ...
    def call(self, inputs, **kwargs): ...
    def build(self, input_shape): ...

class Dense(Layer):
    def __init__(self, units, activation=None, use_bias=True, **kwargs): ...

class Conv2D(Layer):
    def __init__(self, filters, kernel_size, strides=(1, 1), padding='valid', **kwargs): ...

class LSTM(Layer):
    def __init__(self, units, activation='tanh', return_sequences=False, **kwargs): ...

Layers and Building Blocks

Training and Optimization

Optimizers, losses, metrics, and callbacks for training neural networks effectively with various algorithms and monitoring tools.

class Optimizer:
    def __init__(self, learning_rate=0.001, **kwargs): ...

class Adam(Optimizer):
    def __init__(self, learning_rate=0.001, beta_1=0.9, beta_2=0.999, **kwargs): ...

class Loss:
    def __call__(self, y_true, y_pred): ...

class SparseCategoricalCrossentropy(Loss):
    def __init__(self, from_logits=False, **kwargs): ...

class Metric:
    def update_state(self, y_true, y_pred): ...
    def result(self): ...

Training and Optimization

Pre-trained Models

Ready-to-use pre-trained models for computer vision tasks, including VGG, ResNet, MobileNet, EfficientNet, and many others, with ImageNet weights.

def ResNet50(include_top=True, weights='imagenet', input_tensor=None, **kwargs): ...
def VGG16(include_top=True, weights='imagenet', input_tensor=None, **kwargs): ...
def MobileNet(include_top=True, weights='imagenet', input_tensor=None, **kwargs): ...
def EfficientNetB0(include_top=True, weights='imagenet', input_tensor=None, **kwargs): ...

Pre-trained Models

Data Processing and Utilities

Built-in datasets, data preprocessing utilities, image processing functions, and various helper utilities for machine learning workflows.

# Datasets
def load_data(): ...  # Available in mnist, cifar10, cifar100, fashion_mnist, etc.

# Image utilities
def load_img(path, color_mode='rgb', target_size=None, **kwargs): ...
def img_to_array(img, dtype=None): ...
def array_to_img(x, scale=True): ...

# Data utilities
def to_categorical(y, num_classes=None, dtype='float32'): ...
def normalize(x, axis=-1, order=2): ...

Data Processing and Utilities

Activation Functions

Comprehensive set of activation functions for introducing non-linearity in neural networks, including standard activations (ReLU, sigmoid, tanh), advanced functions (GELU, Swish, Mish), and specialized activations.

def relu(x, negative_slope=0.0, max_value=None, threshold=0.0): ...
def sigmoid(x): ...
def tanh(x): ...
def softmax(x, axis=-1): ...
def gelu(x, approximate=False): ...
def silu(x): ...
def mish(x): ...
def leaky_relu(x, negative_slope=0.01): ...

Activation Functions

Model Saving and Serialization

Complete functionality for model persistence, weight management, custom object registration, and serialization utilities for saving and loading models across different formats.

def save_model(model, filepath, overwrite=True, save_format=None, **kwargs): ...
def load_model(filepath, custom_objects=None, compile=True, safe_mode=True): ...
def save_weights(model, filepath, overwrite=True, save_format=None, **kwargs): ...
def load_weights(model, filepath, skip_mismatch=False, by_name=False, **kwargs): ...
def register_keras_serializable(package='Custom', name=None): ...

Model Saving and Serialization

Weight Initializers

Weight initialization strategies for proper model initialization, including constant initializers, random initializers, and variance scaling methods optimized for different activation functions.

class Initializer: ...
class Zeros(Initializer): ...
class Ones(Initializer): ...
class GlorotNormal(Initializer): ...
class GlorotUniform(Initializer): ...
class HeNormal(Initializer): ...
class HeUniform(Initializer): ...
class Orthogonal(Initializer): ...

Weight Initializers

Regularizers

Regularization techniques to prevent overfitting through weight penalties, including L1, L2, combined L1L2, and orthogonal regularization for improved model generalization.

class Regularizer: ...
class L1(Regularizer): ...
class L2(Regularizer): ...
class L1L2(Regularizer): ...
class OrthogonalRegularizer(Regularizer): ...
def l1(l1=0.01): ...
def l2(l2=0.01): ...

Regularizers

Random Operations

Random number generation and sampling functions for various probability distributions, data augmentation, and stochastic operations with seed management for reproducibility.

def normal(shape, mean=0.0, stddev=1.0, dtype=None, seed=None): ...
def uniform(shape, minval=0.0, maxval=1.0, dtype=None, seed=None): ...
def randint(shape, minval, maxval, dtype='int32', seed=None): ...
def dropout(x, rate, noise_shape=None, seed=None): ...
def shuffle(x, axis=0, seed=None): ...
class SeedGenerator: ...

Random Operations

Backend Operations

Low-level operations and backend functionality for tensor operations, mathematical functions, and neural network primitives across different backend engines.

# Core operations
def cast(x, dtype): ...
def shape(x): ...
def reshape(x, shape): ...
def transpose(x, axes=None): ...

# Math operations
def add(x1, x2): ...
def multiply(x1, x2): ...
def matmul(x1, x2): ...
def relu(x): ...
def softmax(x, axis=-1): ...

Backend Operations

Core Types

class KerasTensor:
    """Symbolic tensor representation used in Keras functional API."""
    def __init__(self, type_spec, name=None): ...
    
class Variable:
    """Keras variable for storing mutable state."""
    def __init__(self, initializer, shape=None, dtype=None, **kwargs): ...
    def assign(self, value): ...

class DTypePolicy:
    """Policy for dtype handling in mixed precision training."""
    def __init__(self, name): ...