Releases: rstudio/keras3
keras3 1.3.0
-
Keras now uses
reticulate::py_require()
to resolve Python dependencies.
Callinginstall_keras()
is no longer required (but is still supported). -
use_backend()
gains agpu
argument, to specify if a GPU-capable set of
dependencies should be resolved bypy_require()
. -
The progress bar in
fit()
,evaluate()
andpredict()
now
defaults to not presenting during testthat tests. -
dotty::.
is now reexported. -
%*%
now dispatches toop_matmul()
for tensorflow tensors, which
has relaxed shape constraints compared totf$matmul()
. -
Fixed an issue where calling a
Metric
andLoss
object
with unnamed arguments would error.
Added compatibility with Keras v3.8.0. User-facing changes:
-
New symbols:
activation_sparse_plus()
activation_sparsemax()
activation_threshold()
layer_equalization()
layer_mix_up()
layer_rand_augment()
layer_random_color_degeneration()
layer_random_color_jitter()
layer_random_grayscale()
layer_random_hue()
layer_random_posterization()
layer_random_saturation()
layer_random_sharpness()
layer_random_shear()
op_diagflat()
op_sparse_plus()
op_sparsemax()
op_threshold()
op_unravel_index()
-
Add argument axis to tversky loss
-
New: ONNX model export with
export_savedmodel()
-
Doc improvements and bug fixes.
-
JAX specific changes: Add support for JAX named scope
-
TensorFlow specific changes: Make
random_shuffle()
XLA compilable
Added compatibility with Keras v3.7.0. User-facing changes:
New functions
Activations
activation_celu()
activation_glu()
activation_hard_shrink()
activation_hard_tanh()
activation_log_sigmoid()
activation_soft_shrink()
activation_squareplus()
activation_tanh_shrink()
Configuration
config_disable_flash_attention()
config_enable_flash_attention()
config_is_flash_attention_enabled()
Layers and Initializers
initializer_stft()
layer_max_num_bounding_boxes()
layer_stft_spectrogram()
Losses and Metrics
loss_circle()
metric_concordance_correlation()
metric_pearson_correlation()
Operations
op_celu()
op_exp2()
op_glu()
op_hard_shrink()
op_hard_tanh()
op_ifft2()
op_inner()
op_soft_shrink()
op_squareplus()
op_tanh_shrink()
New arguments
callback_backup_and_restore()
: Addeddouble_checkpoint
argument to save a fallback checkpointcallback_tensorboard()
: Added support forprofile_batch
argumentlayer_group_query_attention()
: Addedflash_attention
andseed
argumentslayer_multi_head_attention()
: Addedflash_attention
argumentmetric_sparse_top_k_categorical_accuracy()
: Addedfrom_sorted_ids
argument
Performance improvements
- Added native Flash Attention support for GPU (via cuDNN) and TPU (via Pallas kernel) in JAX backend
- Added opt-in native Flash Attention support for GPU in PyTorch backend
- Enabled additional kernel fusion via bias_add in TensorFlow backend
- Added support for Intel XPU devices in PyTorch backend
install_keras()
changes: if a GPU is available, the default is now to
install a CPU build of TensorFlow and a GPU build of JAX. To use a GPU in the
current session, calluse_backend("jax")
.
Added compatibility with Keras v3.6.0. User-facing changes:
Breaking changes:
- When using
get_file()
withextract = TRUE
oruntar = TRUE
, the return value
is now the path of the extracted directory, rather than the path of the archive.
Other changes and additions:
-
Logging is now asynchronous in
fit()
,evaluate()
, andpredict()
. This
enables 100% compact stacking oftrain_step
calls on accelerators (e.g. when
running small models on TPU).- If you are using custom callbacks that rely on
on_batch_end
, this will
disable async logging. You can re-enable it by adding
self$async_safe <- TRUE
to your callbacks. Note that the TensorBoard
callback is not considered async-safe by default. Default callbacks like the
progress bar are async-safe.
- If you are using custom callbacks that rely on
-
New bitwise operations:
op_bitwise_and()
op_bitwise_invert()
op_bitwise_left_shift()
op_bitwise_not()
op_bitwise_or()
op_bitwise_right_shift()
op_bitwise_xor()
-
New math operations:
op_logdet()
op_trunc()
op_histogram()
-
New neural network operation:
op_dot_product_attention()
-
New image preprocessing layers:
layer_auto_contrast()
layer_solarization()
-
New Model functions
get_state_tree()
andset_state_tree()
, for retrieving
all model variables, including trainable, non-trainable, optimizer variables,
and metric variables. -
New
layer_pipeline()
for composing a sequence of layers. This class is useful
for building a preprocessing pipeline. Compared to akeras_model_sequential()
,
layer_pipeline()
has a few key differences:- It's not a Model, just a plain layer.
- When the layers in the pipeline are compatible with
tf.data
, the pipeline
will also remaintf.data
compatible, regardless of the backend you use.
-
New argument:
export_savedmodel(verbose = )
-
New argument:
op_normalize(epsilon = )
-
Various documentation improvements and bug fixes.
keras3 1.2.0
-
Added compatibility with Keras v3.5.0. User facing changes:
- New functions:
op_associative_scan()
op_searchsorted()
optimizer_lamb()
keras$DTypePolicy
instances can now be supplied todtype
argument for
losses, metrics, and layers.- Add integration with the Hugging Face Hub. You can now save models to
Hugging Face Hub directlysave_model()
and load .keras models directly
from Hugging Face Hub withload_model()
. - Added compatibility with NumPy 2.0.
- Improved
keras$distribution
API support for very large models. - Bug fixes and performance improvements.
- Add
data_format
argument tolayer_zero_padding_1d()
layer. - Miscellaneous documentation improvements.
- Bug fixes and performance improvements.
- New functions:
keras3 1.1.0
-
Fixed issue where GPUs would not be found when running on Windows under WSL Linux.
(reported in #1456, fixed in #1459) -
keras_shape
objects (as returned bykeras3::shape()
) gain==
and!=
methods. -
Fixed warning from
tfruns::training_run()
being unable to log optimizer learning rate. -
Added compatibility with Keras v3.4.1 (no R user facing changes).
-
Added compatibility with Keras v3.4.0. User facing changes:
-
New functions:
op_argpartition()
op_map()
op_scan()
op_switch()
op_dtype()
op_lstsq()
op_image_hsv_to_rgb()
op_image_rgb_to_hsv()
-
Changes:
- Added support for arbitrary, deeply nested input/output structures in
Functional models (e.g. lists of lists of lists of inputs or outputs...) - Add support for
optional
Functional inputs.keras_input()
gains anoptional
argument.keras_model_sequential()
gains ainput_optional
argument.
- Add support for
float8
inference forDense
andEinsumDense
layers. - Enable
layer_feature_space()
to be used in a{tfdatasets}
pipeline even
when the backend isn't TensorFlow. layer_string_lookup()
can now taketf$SparseTensor()
as input.layer_string_lookup()
returns"int64"
dtype by default in more modes now.Layer()
instances gain attributespath
andquantization_mode
.Metric()$variables
is now recursive.- Add
training
argument toModel$compute_loss()
. split_dataset()
now supports nested structures in dataset.- All applications gain a
name
argument, accept a custom name. layer_multi_head_attention()
gains aseed
argument.- All losses gain a
dtype
argument. loss_dice()
gains anaxis
argument.op_ctc_decode()
, new default formask_index = 0
- All
op_image_*
functions now use defaultdata_format
value
toconfig_image_data_format()
op_isclose()
gains argumentsrtol
,atol
,equal_nan
.save_model()
gains argumentzipped
.- Bugs fixes and performance improvements.
- Added support for arbitrary, deeply nested input/output structures in
-
keras3 1.0.0
-
Chains of
layer_*
calls with|>
now instantiate layers in the
same order as%>%
pipe chains: left-hand-side first (#1440). -
iterate()
,iter_next()
andas_iterator()
are now reexported from reticulate.
User facing changes with upstream Keras v3.3.3:
-
new functions:
op_slogdet()
,op_psnr()
-
clone_model()
gains new args:call_function
,recursive
Updated example usage. -
op_ctc_decode()
strategy argument has new default:"greedy"
.
Updated docs. -
loss_ctc()
default name fixed, changed to"ctc"
User facing changes with upstream Keras v3.3.2:
-
new function:
op_ctc_decode()
-
new function:
op_eigh()
-
new function:
op_select()
-
new function:
op_vectorize()
-
new function:
op_image_rgb_to_grayscale()
-
new function:
loss_tversky()
-
new args:
layer_resizing(pad_to_aspect_ratio, fill_mode, fill_value)
-
new arg:
layer_embedding(weights)
for providing an initial weights matrix -
new args:
op_nan_to_num(nan, posinf, neginf)
-
new args:
op_image_resize(crop_to_aspect_ratio, pad_to_aspect_ratio, fill_mode, fill_value)
-
new args:
op_argmax(keepdims)
andop_argmin(keepdims)
-
new arg:
clear_session(free_memory)
for clearing without invoking the garbage collector. -
metric_kl_divergence()
andloss_kl_divergence()
clip inputs
(y_true
andy_pred
) to the[0, 1]
range. -
new
Layer()
attributes:metrics
,dtype_policy
-
Added initial support for float8 training
-
layer_conv_*d()
layers now support LoRa -
op_digitize()
now supports sparse tensors. -
Models and layers now return owned metrics recursively.
-
Add pickling support for Keras models. (e.g., via
reticulate::py_save_object()
)
Note that pickling is not recommended, prefer using Keras saving APIs.
keras 2.15.0
-
Default TensorFlow/Keras version installed by
install_keras()
is now 2.15.
This is the last Tensorflow version where where Keras 2 is the default.
To use Keras with Tensorflow v2.16 and up, use the new {keras3} R package. -
Updates to allow both R packages {keras} and {keras3} to be loaded.
-
Updates for R-devel (4.4).
keras3 0.2.0
New functions:
-
quantize_weights()
: quantize model or layer weights in-place. Currently,
onlyDense
,EinsumDense
, andEmbedding
layers are supported (which is enough to
cover the majority of transformers today) -
layer_mel_spectrogram()
-
layer_flax_module_wrapper()
-
layer_jax_model_wrapper()
-
loss_dice()
-
random_beta()
-
random_binomial()
-
config_set_backend()
: change the backend after Keras has initialized. -
config_dtype_policy()
-
config_set_dtype_policy()
-
New Ops
op_custom_gradient()
op_batch_normalization()
op_image_crop()
op_divide_no_nan()
op_normalize()
op_correlate()
- `
-
New family of linear algebra ops
op_cholesky()
op_det()
op_eig()
op_inv()
op_lu_factor()
op_norm()
op_erfinv()
op_solve_triangular()
op_svd()
-
audio_dataset_from_directory()
,image_dataset_from_directory()
andtext_dataset_from_directory()
gain averbose
argument (defaultTRUE
) -
image_dataset_from_directory()
gainspad_to_aspect_ratio
argument (defaultFALSE
) -
to_categorical()
,op_one_hot()
, andfit()
can now accept R factors,
offset them to be 0-based (reported in#1055
). -
op_convert_to_numpy()
now returns unconverted NumPy arrays. -
op_array()
andop_convert_to_tensor()
no longer error when casting R
doubles to integer types. -
export_savedmodel()
now works with a Jax backend. -
Metric()$add_variable()
method gains arg:aggregration
. -
Layer()$add_weight()
method gains args:autocast
,regularizer
,aggregation
. -
op_bincount()
,op_multi_hot()
,op_one_hot()
, andlayer_category_encoding()
now support sparse tensors. -
op_custom_gradient()
now supports the PyTorch backend -
layer_lstm()
andlayer_gru()
gain arguse_cudnn
, default'auto'
. -
Fixed an issue where
application_preprocess_inputs()
would error if supplied
an R array as input. -
Doc improvements.
keras3 0.1.0
- The package has been rebuilt for Keras 3.0. Refer to for an overview
and https://keras.posit.co for the current up-to-date documentation.
keras 2.13.0
-
Default TF version installed by
install_keras()
is now 2.13. -
Updated layers:
layer_batch_normalization()
updated signature, with changes to options for distributed training.layer_embedding()
gains asparse
argument.
-
Fixed deadlock when an R generator was passed to
fit()
,predict()
, and other endpoints. -
When
fit(verbose = "auto")
is evaluated in the context of a knitr document
(e.g., quarto or rmarkdown document being rendered), verbose will now
default to2
, showing one line per epoch.
keras 2.11.1
- Update S3 method formals per new CRAN requirement (
r_to_py.keras_layer_wrapper()
)
keras 2.11.0
-
Default TensorFlow version installed by
install_keras()
is now 2.11. -
All optimizers have been updated for Keras/TensorFlow version 2.11.
Arguments to all the optimizers have changed. To access the previous
optimizer implementations, use the constructors available at
keras$optimizers$legacy
. For example, usekeras$optimizers$legacy$Adam()
for the previous implementation ofoptimizer_adam()
. -
New optimizer
optimizer_frtl()
. -
updates to layers:
layer_attention()
gainsscore_mode
anddropout
arguments.layer_discretization()
gainsoutput_mode
andsparse
arguments.layer_gaussian_dropout()
andlayer_gaussian_noise()
gain aseed
argument.layer_hashing()
gainsoutput_mode
andsparse
arguments.layer_integer_lookup()
gainsvocabulary_dtype
andidf_weights
arguments.layer_normalization()
gains aninvert
argument.layer_string_lookup()
gains anidf_weights
argument.
-
Fixed issue where
input_shape
supplied to custom layers defined withnew_layer_class()
would result in an error (#1338) -
New
callback_backup_and_restore()
, for resuming an interruptedfit()
call. -
The merging family of layers (
layer_add
,layer_concatenate
, etc.) gain the ability
to accept layers in...
, allowing for easier composition of residual blocks with the pipe%>%
.
e.g. something like this now works:block_1_output <- ... block_2_output <- block_1_output %>% layer_conv_2d(64, 3, activation = "relu", padding = "same") %>% layer_add(block_1_output)
-
model$get_config()
method now returns an R object that can be safely serialized
to rds. -
keras_array()
now reflects unconverted Python objects. This enables passing
objects likepandas.Series()
tofit()
andevaluate()
methods. (#1341)