You provide a huge amount of lines of code, but this actually sums to a single issue: You are extracting 3 integers from next_day_open_values, nx, ny = next_day_open_values.shape. Numpy's reshape expects an array as input, not an integer or single value.

Parameters: numpy.reshape(a, newshape, order='C')

a : array_like - Array to be reshaped.

I doubt you are trying to get a vector of a single integer repeating for the nx*ny shape. Furthermore, if you turn the input into an array, and perform the same operation, you'll run into ValueError because you cannot reshape an array of size 1 into a specific shape.

I believe this might work, but I don't know what next_day_open_values is:

next_day_open_values_s, nx, ny = next_day_open_values.shape
next_day_open_values = next_day_open_values.reshape(next_day_open_values_s,nx*ny)
Answer from Celius Stingher on Stack Overflow
Discussions

Seeing AttributeError: 'Dataset' object has no attribute 'reshape' when using "dataset.get_nearest_examples"
Hello, I am trying to use Faiss indexing for an image similarity application. However, I am seeing an Attribute Error. Here’s the code that I am trying # Loading dataset dataset = load_dataset("imagefolder", data_dir="/… More on discuss.huggingface.co
🌐 discuss.huggingface.co
0
0
June 25, 2023
Getting Attribute error " 'int' object has no attribute 'shape' - Chapter 03
WARNING:tensorflow:11 out of the last 11 calls to triggered tf.function retracing. Tracing is expensive and the exce... More on github.com
🌐 github.com
12
March 3, 2021
Python error 'int' object has no attribute 'shape' - Stack Overflow
Traceback (most recent call last): ...thon3.5/site-packages/sklearn/tree/tree.py", line 371, in _validate_X_predict n_features = X.shape[1] AttributeError: 'int' object has no attribute 'shape'... More on stackoverflow.com
🌐 stackoverflow.com
Getting "AttributeError: 'int' object has no attribute 'shape'" in predict
Hello community! I hope you are doing well. I am stuck in a “predict” function. I followed the steps explained in “Hints” For example, hint said: “# Calculate f_wb (exactly how you did it in the compute_cost function above) # using a couple of lines of code f_wb =” I just copied ... More on community.deeplearning.ai
🌐 community.deeplearning.ai
0
0
August 16, 2022
🌐
GitHub
github.com › pandas-dev › pandas › issues › 37415
BUG: groupby with std aggregation of pandas integer dtype throws exception: 'IntegerArray' object has no attribute 'reshape' · Issue #37415 · pandas-dev/pandas
October 26, 2020 - import pandas as pd df = pd.DataFrame({'a': [1,1,1,2,2],'b': [1,2,3,4,5]}) df['b'] = df['b'].astype(pd.Int32Dtype()) df.groupby('a').agg('std') # Error 'IntegerArray' object has no attribute 'reshape'. The same error occurs with all pandas integer types
Author   hannesdm
🌐
Hugging Face
discuss.huggingface.co › 🤗datasets
Seeing AttributeError: 'Dataset' object has no attribute 'reshape' when using "dataset.get_nearest_examples" - 🤗Datasets - Hugging Face Forums
June 25, 2023 - Hello, I am trying to use Faiss indexing for an image similarity application. However, I am seeing an Attribute Error. Here’s the code that I am trying # Loading dataset dataset = load_dataset("imagefolder", data_dir="/data") # Pre processing images def transforms(examples): examples["image"] = [image.resize((384, 384)).convert("RGB") for image in examples["image"]] return examples # Applying the transform function to dataset dataset = dataset.map(transforms, batched=True, batch_size=...
🌐
GitHub
github.com › PacktPublishing › Generative-Adversarial-Networks-Projects › issues › 70
Getting Attribute error " 'int' object has no attribute 'shape' - Chapter 03 · Issue #70 · PacktPublishing/Generative-Adversarial-Networks-Projects
March 3, 2021 - Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has experimental_relax_shapes=True option that relaxes argument shapes that can avoid unnecessary retracing.
Author   bineetha1995
🌐
CopyProgramming
copyprogramming.com › howto › python-attribute-error-int-object-has-no-attribute-reshape
Python: Reshaping Error in Python: 'Int' Object Lacks 'Reshape' Attribute
May 14, 2023 - The reason for my confusion is that although the statements above and below the non-functioning one are nearly identical and functioning properly, the one in question uses a function instead of an attribute, which is causing my bafflement. ... The distinction between batch_x[i] and corrupt(...) is that the former is a NumPy array with a reshape method, while the latter is a Tensor object that does not have a reshape method as of tf 1.5.
🌐
Python Forum
python-forum.io › thread-13879.html
'list' object has no attribute 'reshape'
November 4, 2018 - Hi All, I've just joined this forum, also new to Python, with background in other languages. I've been trying a small piece of code below using jupyter ipython in notebooks.azure.com, the error is coming from the last call for np.reshape function w...
Find elsewhere
🌐
DeepLearning.AI
community.deeplearning.ai › course q&a › machine learning specialization › supervised ml: regression and classification
Getting "AttributeError: 'int' object has no attribute 'shape'" in predict - Supervised ML: Regression and Classification - DeepLearning.AI
August 16, 2022 - Hello community! I hope you are doing well. I am stuck in a “predict” function. I followed the steps explained in “Hints” For example, hint said: “# Calculate f_wb (exactly how you did it in the compute_cost function above) # using a couple of lines of code f_wb =” I just copied ...
🌐
Researchdatapod
researchdatapod.com › home › how to solve python attributeerror: ‘series’ object has no attribute ‘reshape’
How to Solve Python AttributeError: 'Series' object has no attribute 'reshape' - The Research Scientist Pod
March 30, 2022 - The AttributeError ‘Series’ object has no attribute ‘reshape’ occurs when you try to call the reshape() method on a Series object as if it were a ndarray. To solve this error, you can use values.reshape() to reshape the underlying ndarray ...
🌐
Bobby Hadz
bobbyhadz.com › blog › python-attributeerror-list-object-has-no-attribute-shape
AttributeError: 'list' object has no attribute 'shape' | bobbyhadz
April 8, 2024 - The np.reshape() method takes an array-like object as an argument and an int or tuple of integers that represent the new shape.
🌐
GitHub
github.com › Theano › Theano › issues › 1935
Elemwise perform: AttributeError: 'int' object has no attribute 'shape' · Issue #1935 · Theano/Theano
June 21, 2014 - I've stumbled upon a situation where, during graph optimization, a pure Python 'int' is passed to Elemwise.perform, but the current implementation expects a NumPy array because it assumes the 'shape' attribute (theano/tensor/elemwise.py:778). I'm not sure about the correct fix.
Author   sisp
🌐
Data Science Learner
datasciencelearner.com › home › attributeerror : ‘list’ object has no attribute ‘reshape’ ( solved )
AttributeError : 'list' object has no attribute 'reshape' ( Solved )
February 12, 2023 - You can see the shape of the array has been changed to 3 rows and 2 columns. The list is widely used by python programmers. If you want to change the dimensions of the list then convert it into a numpy array first as the reshape() method is a function of the numpy module. The above solution will solve the no attribute ‘reshape’ error.
🌐
GitHub
github.com › hacksider › Deep-Live-Cam › issues › 577
AttributeError: 'NoneType' object has no attribute 'reshape' · Issue #577 · hacksider/Deep-Live-Cam
September 13, 2024 - Applied providers: ['CPUExecutionProvider'], with options: {'CPUExecutionProvider': {}} inswapper-shape: [1, 3, 128, 128] Exception in Tkinter callback Traceback (most recent call last): File "D:\anaconda3\envs\nev1-deep_live_cam_python310\lib\tkinter_init_.py", line 1921, in call return self.func(*args) File "D:\anaconda3\envs\nev1-deep_live_cam_python310\lib\site-packages\customtkinter\windows\widgets\ctk_button.py", line 554, in _clicked self._command() File "D:\pythoncode\CV\deepfakes\Deep-Live-Cam\new_model\modules\ui.py", line 132, in start_button = ctk.CTkButton(root, text='Start', curs
Author   mrbingo1024
Top answer
1 of 2
1

Your current approach involves nested loops and reshaping, which can be quite slow. Instead of using np.append within loops, consider using numpy.roll for efficient pixel shifting. Using numpy.roll, you can achieve the desired image shifts using numpy.roll. Here’s an example of how to do it:

import numpy as np
from scipy.ndimage.interpolation import shift
from keras.datasets import mnist

# Load MNIST dataset
(x_train, y_train), _ = mnist.load_data()

def shift_image(image, shift_x, shift_y):
    return np.roll(image, (shift_x, shift_y), axis=(0, 1)).reshape(-1)

# Create shifted copies for each direction
X_train_expansion = []
y_train_expansion = []

for shift_x, shift_y in ((0, 1), (0, -1), (1, 0), (-1, 0)):
    for image, label in zip(x_train, y_train):
        shifted_image = shift_image(image, shift_x, shift_y)
        X_train_expansion.append(shifted_image)
        y_train_expansion.append(label)

X_train_expansion = np.array(X_train_expansion)
y_train_expansion = np.array(y_train_expansion)
2 of 2
1

According to the error message, the problem is with the output variable in the shift function. While it occurs several layers down it appears that output is an int, while output.shape indicates it should be an array (a class of objects that has a shape attribute).

Looking at the shift docs, I see the signature is:

shift(input, shift, output=None, ...)

where output is supposed to be an array. shift can be a scalar, or a sequence.

You call it with:

shift(image, shift_x, shift_y)

Your 3rd argument is shift_y, not a output array.

the fix? Calling the shift function with the right kinds of arguments, the kinds specified in the documentation.

shift(image, (shift_x, shift_y))
🌐
Quora
quora.com › What-does-attributeerror-int-object-has-no-attribute-value-mean-How-do-you-fix-it-python-tensorflow-tensorflow2-0-development
What does 'attributeerror: 'int' object has no attribute 'value'' mean? How do you fix it (python, tensorflow, tensorflow2.0, development)? - Quora
Answer (1 of 2): Depending on the script you’re trying to run, there can be many causes for this error. However, it is most often seen when trying to run a script made for TensorFlow 1.x on TensorFlow 2.x or vice-versa. This is because TensorFlow 2.x is not meant to be backward compatible with Te...
🌐
GitHub
github.com › pandas-dev › pandas › issues › 35731
BUG: Series has no attribute "reshape" after adding a new category in df · Issue #35731 · pandas-dev/pandas
August 14, 2020 - We are trying to add the new fillna ... functionality. Running the above snippet will get us the attribute error AttributeError: 'Series' object has no attribute 'reshape'...
Author   chen-bowen