AI编程

Keras

Python版本的TensorFlow深度学习API

标签:

Keras is a deep learning library with pluggable backends. Write models once and run them on JAX, PyTorch, TensorFlow, and more, from laptop to TPU.

A superpower for ML developers

Keras 3 is the high-level API for building, training, and shipping models on the backend of your choice: JAX, PyTorch, MLX, and more.

Welcome to multi-framework machine learning

inputs = keras.Input(shape=(32, 32, 3)) x = layers.Conv2D(32, 3, activation="relu")(inputs) x = layers.Conv2D(64, 3, activation="relu")(x) residual = x = layers.MaxPooling2D(3)(x) x = layers.Conv2D(64, 3, padding="same")(x) x = layers.Activation("relu")(x) x = layers.Conv2D(64, 3, padding="same")(x) x = layers.Activation("relu")(x) x = x + residual x = layers.Conv2D(64, 3, activation="relu")(x) x = layers.GlobalAveragePooling2D()(x) outputs = layers.Dense(10, activation="softmax")(x) model = keras.Model(inputs, outputs, name="mini_resnet") keras.utils.plot_model(model, "mini_resnet.png") model.fit(dataset, epochs=10) Run quickstart Copied causal_lm = keras_hub.models.CausalLM.from_preset( "gemma4_instruct_2b", dtype="bfloat16", ) prompt = """<|turn>user Write python code to print the first 100 primes.<turn|> <|turn>model """ text_output = causal_lm.generate(prompt, max_length=512) text_to_image = keras_hub.models.TextToImage.from_preset( "stable_diffusion_3_medium", dtype="float16", ) prompt = "Astronaut in a jungle, detailed" image_output = text_to_image.generate(prompt) Run quickstart Welcome to multi-framework machine learning With its multi-backend approach, Keras gives you the freedom to work with JAX, TensorFlow, and PyTorch. Build models that can move seamlessly across these frameworks and leverage the strengths of each ecosystem.

Developer Guides

inputs = keras.Input(shape=(28, 28, 1)) x = inputs x = layers.Conv2D(16, 3, activation="relu")(x) x = layers.Conv2D(32, 3, activation="relu")(x) x = layers.MaxPooling2D(3)(x) x = layers.Conv2D(32, 3, activation="relu")(x) x = layers.Conv2D(16, 3, activation="relu")(x) x = layers.GlobalMaxPooling2D()(x) x = layers.Dropout(0.5)(x) outputs = layers.Dense(10)(x) model = keras.Model(inputs, outputs) model.summary() The Functional API Starting from the beginning and learn how to build models using the functional building pattern.

数据统计

相关导航

暂无评论

暂无评论...