Skip to content

Releases: rstudio/keras3

keras3 1.2.0

06 Sep 11:46
10983c8
Compare
Choose a tag to compare
  • 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 to dtype argument for
      losses, metrics, and layers.
    • Add integration with the Hugging Face Hub. You can now save models to
      Hugging Face Hub directly save_model() and load .keras models directly
      from Hugging Face Hub with load_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 to layer_zero_padding_1d() layer.
    • Miscellaneous documentation improvements.
    • Bug fixes and performance improvements.

keras3 1.1.0

17 Jul 13:54
Compare
Choose a tag to compare
  • 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 by keras3::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 an optional argument.
        • keras_model_sequential() gains a input_optional argument.
      • Add support for float8 inference for Dense and EinsumDense layers.
      • Enable layer_feature_space() to be used in a {tfdatasets} pipeline even
        when the backend isn't TensorFlow.
      • layer_string_lookup() can now take tf$SparseTensor() as input.
      • layer_string_lookup() returns "int64" dtype by default in more modes now.
      • Layer() instances gain attributes path and quantization_mode.
      • Metric()$variables is now recursive.
      • Add training argument to Model$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 a seed argument.
      • All losses gain a dtype argument.
      • loss_dice() gains an axis argument.
      • op_ctc_decode(), new default for mask_index = 0
      • All op_image_* functions now use default data_format value
        to config_image_data_format()
      • op_isclose() gains arguments rtol, atol, equal_nan.
      • save_model() gains argument zipped.
      • Bugs fixes and performance improvements.

keras3 1.0.0

21 May 17:13
Compare
Choose a tag to compare
  • Chains of layer_* calls with |> now instantiate layers in the
    same order as %>% pipe chains: left-hand-side first (#1440).

  • iterate(), iter_next() and as_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) and op_argmin(keepdims)

  • new arg: clear_session(free_memory) for clearing without invoking the garbage collector.

  • metric_kl_divergence() and loss_kl_divergence() clip inputs
    (y_true and y_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

23 Apr 12:59
Compare
Choose a tag to compare
  • 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

18 Apr 13:45
Compare
Choose a tag to compare

New functions:

  • quantize_weights(): quantize model or layer weights in-place. Currently,
    only Dense, EinsumDense, and Embedding 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() and text_dataset_from_directory() gain a verbose argument (default TRUE)

  • image_dataset_from_directory() gains pad_to_aspect_ratio argument (default FALSE)

  • to_categorical(), op_one_hot(), and fit() 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() and op_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(), and layer_category_encoding() now support sparse tensors.

  • op_custom_gradient() now supports the PyTorch backend

  • layer_lstm() and layer_gru() gain arg use_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

19 Feb 13:55
2147361
Compare
Choose a tag to compare
  • 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

15 Aug 21:13
Compare
Choose a tag to compare
  • 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 a sparse 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 to 2, showing one line per epoch.

keras 2.11.1

23 Mar 18:45
Compare
Choose a tag to compare
  • Update S3 method formals per new CRAN requirement (r_to_py.keras_layer_wrapper())

keras 2.11.0

20 Dec 15:38
Compare
Choose a tag to compare
  • 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, use keras$optimizers$legacy$Adam()
    for the previous implementation of optimizer_adam().

  • New optimizer optimizer_frtl().

  • updates to layers:

    • layer_attention() gains score_mode and dropout arguments.
    • layer_discretization() gains output_mode and sparse arguments.
    • layer_gaussian_dropout() and layer_gaussian_noise() gain a seed argument.
    • layer_hashing() gains output_mode and sparse arguments.
    • layer_integer_lookup() gains vocabulary_dtype and idf_weights arguments.
    • layer_normalization() gains an invert argument.
    • layer_string_lookup() gains an idf_weights argument.
  • Fixed issue where input_shape supplied to custom layers defined with new_layer_class()
    would result in an error (#1338)

  • New callback_backup_and_restore(), for resuming an interrupted fit() 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 like pandas.Series() to fit() and evaluate() methods. (#1341)

keras 2.9.0

23 May 20:34
Compare
Choose a tag to compare
  • New functions for constructing custom keras subclasses:

    • new_model_class()
    • new_layer_class()
    • new_callback_class()
    • new_metric_class()
    • new_loss_class()
    • new_learning_rate_schedule_class().

    Also provided is mark_active(), a decorator for indicating a class method
    should be an active binding (i.e., decorated with Python's @property).
    mark_active() can be used in the new_*_class family of class constructors
    as well as %py_class%.

  • r_to_py() method for R6 classes and %py_class% gain support for
    private fields and methods. Any R objects stored in private will only be
    available to methods, and will not be converted to Python.

  • New family of functions for controlling optimizer learning rates during training:

    • learning_rate_schedule_cosine_decay()
    • learning_rate_schedule_cosine_decay_restarts()
    • learning_rate_schedule_exponential_decay()
    • learning_rate_schedule_inverse_time_decay()
    • learning_rate_schedule_piecewise_constant_decay()
    • learning_rate_schedule_polynomial_decay()

    Also, a function for constructing custom learning rate schedules:
    new_learning_rate_schedule_class().

  • New L2 unit normilization layer: layer_unit_normalization().

  • New regularizer_orthogonal, a regularizer that encourages
    orthogonality between the rows (or columns) or a weight matrix.

  • New zip_lists() function for transposing lists, optionally matching by name.

  • New plot() S3 method for models.

  • pydot is now included in the packages installed by install_keras().

  • The png package is now listed under Suggests.

  • The %<>% assignment pipe from magrittr is exported.

  • format() method for keras models (and derivative methods print(), summary(),
    str(), and py_str()):

    • gain a new arg compact. If TRUE (the default) white-space only
      lines are stripped out of model.summary().
    • If any layers are marked non-trainable or frozen, the model summary
      now includes a "Trainable" column, indicating if a layer is frozen.
  • freeze_weights() and unfreeze_weights():

    • gain a flexible which argument that can accept layer names (as character strings),
      an integer vector, a boolean vector, or a function that returns a boolean
      when called with a layer. (see updated examples in ?freeze_weights
    • from and to arguments gain the ability to accept negative integers,
      to specify layers counting from the end of the layers list.
  • get_weights() gains a trainable argument that can accept TRUE or FALSE,
    allowing for returning only the unfrozen or frozen weights, respectively.

  • timeseries_dataset_from_array():

    • R arrays are now cast to the floatx dtype ("float32" by default)
    • start_index and end_index now are 1-based.
  • image_dataset_from_directory() gains a crop_to_aspect_ratio argument which
    can be used to prevent distorting images when resizing to a new aspect ratio.

  • Layer is deprecated, superseded by new_layer_class().

  • load_model_tf() argument custom_objects gains the ability to accept an
    unnamed list (e.g, of objects returned by new_layer_class() or similar).
    Appropriate names for the supplied objects are automatically inferred.

  • Fixed an issue where negative values less than -1 supplied to axis
    arguments were selecting the wrong axis.

  • get_layer() gains the ability to accept negative values for the index argument.

  • Fixed warning from create_layer_wrapper() when the custom layer didn't have
    an overridden initialize or __init__ method.

  • Backend functions:

    • k_clip() min_value and max_value gain default values of NULL,
      can be omitted. NULL is taken as -Inf or Inf, respectively.
    • k_squeeze(): axis argument can be omitted, in which case all axes of size 1 are dropped.
    • k_tile(): n argument can now be supplied as a tensor.
    • New function k_unstack().
  • KerasTensor objects (e.g, returned by layer_input()) now inherit S3 methods
    for "tensorflow.tensor".

  • plot.keras_training_history() no longer issues message
    `geom_smooth()` using formula 'y ~ x' when method = "ggplot2".

  • print and related methods for models (format, summary) now accept
    a width argument.

  • evaluate(), fit(), and predict() methods for keras Models now default
    to verbose = "auto", with verbosity adjusted appropriately based on calls to
    keras$utils$disable_interactive_logging(), and contexts like
    ParameterServerStrategy.

  • install_keras() now accepts version = "release-cpu" as a valid specification.