|
y_batch = np.resize(y_batch,[BATCH_SIZE,1]) |
Current code:
y_batch = np.resize(y_batch, [BATCH_SIZE, 1])
Proposed replacement:
y_batch = np.reshape(y_batch, [BATCH_SIZE, 1])
np.reshape changes the view/shape of an array only if the element count matches. If not compatible, it raises an error — making issues explicit and avoiding silent bugs.
np.resize will always return the requested shape. If the target shape has more elements, it repeats data to fill it; if fewer, it truncates data. This can corrupt labels in y_batch without warning.
Performance: reshape is faster and more memory-efficient because it typically returns a view instead of creating new data.
Robustness: For supervised learning, label arrays (y_batch) should not be silently duplicated or truncated. Using reshape ensures consistency and correctness.
DDPG/ddpg.py
Line 66 in 18825ee
Current code:
y_batch = np.resize(y_batch, [BATCH_SIZE, 1])Proposed replacement:
y_batch = np.reshape(y_batch, [BATCH_SIZE, 1])np.reshape changes the view/shape of an array only if the element count matches. If not compatible, it raises an error — making issues explicit and avoiding silent bugs.
np.resize will always return the requested shape. If the target shape has more elements, it repeats data to fill it; if fewer, it truncates data. This can corrupt labels in y_batch without warning.
Performance: reshape is faster and more memory-efficient because it typically returns a view instead of creating new data.
Robustness: For supervised learning, label arrays (y_batch) should not be silently duplicated or truncated. Using reshape ensures consistency and correctness.