Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ops.copy makes object (arrays only?) immutable #19665

Closed
Mrutyunjay01 opened this issue May 4, 2024 · 1 comment
Closed

ops.copy makes object (arrays only?) immutable #19665

Mrutyunjay01 opened this issue May 4, 2024 · 1 comment
Assignees

Comments

@Mrutyunjay01
Copy link
Contributor

Issue:

When trying to overwrite an object after making a copy using ops.copy, it makes the object immutable. Even after explicitly converting to numpy using ops.convert_to_numpy, the copied object remains immutable.

How to Reproduce:

import numpy as np
from keras import ops

arr = np.arange(10)
ops_arr = ops.copy(arr)

print(type(ops_arr)) # now it's EagerTensor

ops_arr_np = ops.convert_to_numpy(ops_arr)
print(ops_arr_np) # of type ndarray

ops_arr_np[0] = 10

And the error that follows:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
# in <cell line: 9>()
      7 print(ops_arr_np) # of type ndarray
      8 
----> 9 ops_arr_np[0] = 10

ValueError: assignment destination is read-only
@fchollet
Copy link
Member

fchollet commented May 4, 2024

Thanks for the report, this is now fixed at HEAD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants