def test_reshape(): jp.set_context_dtype('float64') shapes = [[(2, 3), (6, 1)], [(1, 2, 3), (3, 2)], [(3, 2, 1), (2, -1)], [(3, 1, 2), (-1, 3, 1)]] for shape1, shape2 in shapes: x_np = np.random.random(shape1) y_np = np.reshape(x_np, shape2) x_jp = jp.array(x_np) y_jp = jp.reshape(x_jp, shape2) assert y_jp.shape == y_np.shape
def test_reshape(): jp.set_context_dtype('float64') shapes = [ [(2, 3), (6, 1)], [(1, 2, 3), (3, 2)], [(3, 2, 1), (2, -1)], [(3, 1, 2), (-1, 3, 1)] ] for shape1, shape2 in shapes: x_np = np.random.random(shape1) y_np = np.reshape(x_np, shape2) x_jp = jp.array(x_np) y_jp = jp.reshape(x_jp, shape2) assert y_jp.shape == y_np.shape
# # SPDX-License-Identifier: Apache-2.0 ################################################################################ import jumpy as jp # Basic example # Create an array: x = jp.zeros((32, 10, 12)) # Reshape: x = jp.reshape(x, (32, 120)) # Reduction ops: sum_ = x.sum(axis=1) mean = x.mean(axis=1) std = x.std(axis=1) max_ = x.max(axis=0) min_ = x.min(axis=0) # Inplace ops: y = jp.ones((32, 120)) x += y # Broadcasting: