in Education by
I have a variable of z storing features of length and height of image files where z is z = [length, height] and i want to change these dimension to just: z = [area] where area = length * height I tried using the numpy reshape function as follow: area = z.shape[0] * z.shape[1] #length * height z = z.reshape(-1) #was trying to reduce to just z = [area] but it seemed like I'm not using the reshape function correctly. Could anyone help me out? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Simple example of how to use reshape: import numpy as np a = np.random.randint(0,10,(10,10)) b = np.reshape(a, (100,)) print(b) For your case it will be: print(a.shape) # prints (length,height) b = np.reshape(a, (length * height,)) print(b.shape) # prints (length * height,) To perform a reshape in place you can also use: a.shape = ((100,))

Related questions

0 votes
    I have a variable of z storing features of length and height of image files where z is z = [ ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 1, 2022 in Education by JackTerrance
0 votes
    When I try to generate a model with acumos I get this error : File "/Users/fredericchantrel/.pyenv/ ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
0 votes
    In [31]: print(np.poly1d((3,2))) 3 x + 2 In [32]: a = np.array(( np.poly1d( ... JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I have a dataset that only contains y-values in one column. I want to insert a column of x- ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I want to encode a 1-D numpy array: x = array([1,0,3]) As a 2-D 1-hot array y = array([ ... some faster technique other than looping. Select the correct answer from above options...
asked Jan 22, 2022 in Education by JackTerrance
0 votes
    I have the 4D array, which is defined as follows: B = np.array( [[[[0.5000, 0.5625], [0.5000, ... loops and ideally one function call. Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    How do you think I can get the intersection of the below-given array? a=np.array([[[[0,0],[0,1]],[[1,1],[1,1]]] ... , [[0, 1], [1, 1]]] Select the correct answer from above options...
asked Jan 9, 2022 in Education by JackTerrance
0 votes
    What will be the output of the following Python function? min(max(False,-3,-4), 2,7) a) -4 b) -3 c) 2 d) False...
asked Jan 2, 2023 in Technology by JackTerrance
0 votes
    I can use vi{ and va{ to select C++ code blocks. It helps me a lot when I need to yank ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Aug 1, 2022 in Education by JackTerrance
0 votes
    I have two list that I combine into a single list. Later I want to make a copy of this list so ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 27, 2022 in Education by JackTerrance
0 votes
    I have an object with an attribute that is a list. For example: obj.a = [3, 4, 5] I ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    I'm curious about manipulating time in Python. I can get the (last modified) age of a file using ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    I have an object with an attribute that is a list. For example: obj.a = [3, 4, 5] I ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 30, 2022 in Education by JackTerrance
0 votes
    I want to run a python script from a shell script. I have been able to run it from the "command ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 26, 2022 in Education by JackTerrance
0 votes
    I want to run a python script from a shell script. I have been able to run it from the "command ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 10, 2022 in Education by JackTerrance
...