keras-nightly 3.12.0.dev2025082503__py3-none-any.whl → 3.12.0.dev2025082603__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,13 +11,12 @@ class Reshape(Layer):
11
11
 
12
12
  Args:
13
13
  target_shape: Target shape. Tuple of integers, does not include the
14
- samples dimension (batch size).
14
+ samples dimension (batch size). One element of the `target_shape`
15
+ can be -1 in which case the missing value is inferred from the
16
+ size of the array and remaining dimensions.
15
17
 
16
18
  Input shape:
17
- Arbitrary, although all dimensions in the input shape must be
18
- known/fixed. Use the keyword argument `input_shape` (tuple of integers,
19
- does not include the samples/batch size axis) when using this layer as
20
- the first layer in a model.
19
+ Arbitrary, but required to be compatible with `target_shape`.
21
20
 
22
21
  Output shape:
23
22
  `(batch_size, *target_shape)`
@@ -29,7 +28,7 @@ class Reshape(Layer):
29
28
  >>> y.shape
30
29
  (None, 3, 4)
31
30
 
32
- >>> # also supports shape inference using `-1` as dimension
31
+ >>> # another example with shape inference using `-1` as dimension
33
32
  >>> y = keras.layers.Reshape((-1, 2, 2))(x)
34
33
  >>> y.shape
35
34
  (None, 3, 2, 2)
@@ -37,7 +36,15 @@ class Reshape(Layer):
37
36
 
38
37
  def __init__(self, target_shape, **kwargs):
39
38
  super().__init__(**kwargs)
40
- self.target_shape = tuple(target_shape)
39
+ target_shape = tuple(target_shape)
40
+ # test validity of target_shape
41
+ if target_shape.count(-1) > 1:
42
+ raise ValueError(
43
+ "The `target_shape` argument must not contain more than one "
44
+ f"`-1` value. Received: target_shape={target_shape}"
45
+ )
46
+ self.target_shape = target_shape
47
+ self.built = True
41
48
 
42
49
  def compute_output_shape(self, input_shape):
43
50
  return (
@@ -53,17 +60,17 @@ class Reshape(Layer):
53
60
  shape=output_shape, dtype=inputs.dtype, sparse=inputs.sparse
54
61
  )
55
62
 
56
- def build(self, input_shape):
57
- sample_output_shape = operation_utils.compute_reshape_output_shape(
58
- input_shape[1:], self.target_shape, "target_shape"
63
+ def call(self, inputs):
64
+ potentially_resolved_target_shape = (
65
+ operation_utils.compute_reshape_output_shape(
66
+ tuple(inputs.shape)[1:], self.target_shape, "target_shape"
67
+ )
59
68
  )
60
- self._resolved_target_shape = tuple(
61
- -1 if d is None else d for d in sample_output_shape
69
+ potentially_resolved_target_shape = tuple(
70
+ -1 if d is None else d for d in potentially_resolved_target_shape
62
71
  )
63
-
64
- def call(self, inputs):
65
72
  return ops.reshape(
66
- inputs, (ops.shape(inputs)[0],) + self._resolved_target_shape
73
+ inputs, (ops.shape(inputs)[0],) + potentially_resolved_target_shape
67
74
  )
68
75
 
69
76
  def get_config(self):
keras/src/version.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from keras.src.api_export import keras_export
2
2
 
3
3
  # Unique source of truth for the version number.
4
- __version__ = "3.12.0.dev2025082503"
4
+ __version__ = "3.12.0.dev2025082603"
5
5
 
6
6
 
7
7
  @keras_export("keras.version")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: keras-nightly
3
- Version: 3.12.0.dev2025082503
3
+ Version: 3.12.0.dev2025082603
4
4
  Summary: Multi-backend Keras
5
5
  Author-email: Keras team <keras-users@googlegroups.com>
6
6
  License: Apache License 2.0
@@ -126,7 +126,7 @@ keras/regularizers/__init__.py,sha256=542Shphw7W8h4Dyf2rmqMKUECVZ8IVBvN9g1LWhz-b
126
126
  keras/saving/__init__.py,sha256=KvL2GZxjvgFgEhvEnkvqjIR9JSNHKz-NWZacXajsjLI,1298
127
127
  keras/src/__init__.py,sha256=Gi4S7EiCMkE03PbdGNpFdaUYySWDs_FcAJ8Taz9Y1BE,684
128
128
  keras/src/api_export.py,sha256=gXOkBOnmscV013WAc75lc4Up01-Kkg9EylIAT_QWctg,1173
129
- keras/src/version.py,sha256=sUqhAki7JkdOdIYrPV9_h-x-aP519FDuVr9K-ZklG4g,204
129
+ keras/src/version.py,sha256=5qtxNmOZ5WnYdRVIC5uk0hcrq7HL9pPmEMCb_9CGGHM,204
130
130
  keras/src/activations/__init__.py,sha256=0nL3IFDB9unlrMz8ninKOWo-uCHasTUpTo1tXZb2u44,4433
131
131
  keras/src/activations/activations.py,sha256=mogPggtp4CGldI3VOPNmesRxp6EbiR1_i4KLGaVwzL8,17614
132
132
  keras/src/applications/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -425,7 +425,7 @@ keras/src/layers/reshaping/cropping3d.py,sha256=Hm176o-duFkIXiAYjvjRAY6mWypY_vSE
425
425
  keras/src/layers/reshaping/flatten.py,sha256=enyah_80RbzDFIHsa9nDvKDl0vfPMSfhwuOhpkwyUpI,3212
426
426
  keras/src/layers/reshaping/permute.py,sha256=F3BxIPmPBnQGSmK2CxW4udFRRAuGKuZaomt-C2luUTs,2090
427
427
  keras/src/layers/reshaping/repeat_vector.py,sha256=Gv8DRO145ooHBriDLvzitmKQJtx-ek0o7EPStPx_Pac,1335
428
- keras/src/layers/reshaping/reshape.py,sha256=pPhUMgr3xOYAzKYQtLQXIssEIwW0ScojJofdx1cango,2296
428
+ keras/src/layers/reshaping/reshape.py,sha256=uepx-x-FGYYBXxE-SLQ0EYRiNxEyN4BZoA6bDyOn-BY,2650
429
429
  keras/src/layers/reshaping/up_sampling1d.py,sha256=xJUqfpYUyc9x461UV_TMPDaCcy1_whKAknIHLkCcbhI,1591
430
430
  keras/src/layers/reshaping/up_sampling2d.py,sha256=Q0YnAVgFQa2Wj1O2_kLPre0CBF9qg53yMRpDxRklzI4,6143
431
431
  keras/src/layers/reshaping/up_sampling3d.py,sha256=nlK1wE5UCuTUsCGJKYkZixOGvxVE20f-H26hTnCyUU4,4910
@@ -597,7 +597,7 @@ keras/utils/bounding_boxes/__init__.py,sha256=jtvQll4u8ZY0Z96HwNhP1nxWEG9FM3gI-6
597
597
  keras/utils/legacy/__init__.py,sha256=oSYZz6uS8UxSElRaaJYWJEoweJ4GAasZjnn7fNaOlog,342
598
598
  keras/visualization/__init__.py,sha256=UKWmiy6sps4SWlmQi9WX8_Z53cPpLlphz2zIeHdwJpQ,722
599
599
  keras/wrappers/__init__.py,sha256=QkS-O5K8qGS7C3sytF8MpmO6PasATpNVGF8qtb7Ojsw,407
600
- keras_nightly-3.12.0.dev2025082503.dist-info/METADATA,sha256=wY0PihAizxkilTPbO5iFBiubxDGBDwT4LTqZm5qvi1o,5970
601
- keras_nightly-3.12.0.dev2025082503.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
602
- keras_nightly-3.12.0.dev2025082503.dist-info/top_level.txt,sha256=ptcw_-QuGZ4ZDjMdwi_Z0clZm8QAqFdvzzFnDEOTs9o,6
603
- keras_nightly-3.12.0.dev2025082503.dist-info/RECORD,,
600
+ keras_nightly-3.12.0.dev2025082603.dist-info/METADATA,sha256=TxxllpHfFQEkuyfpudFgtxRNMvna-9yuSVY5a0Vz9is,5970
601
+ keras_nightly-3.12.0.dev2025082603.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
602
+ keras_nightly-3.12.0.dev2025082603.dist-info/top_level.txt,sha256=ptcw_-QuGZ4ZDjMdwi_Z0clZm8QAqFdvzzFnDEOTs9o,6
603
+ keras_nightly-3.12.0.dev2025082603.dist-info/RECORD,,