2

Matrix Flatten

Unsolved
Fundamentals
Neural Networks

Difficulty: 1 | Problem written by zeyad_omar
Problem reported in interviews at

Amazon
Apple
Facebook
Google
Netflix

In deep learning, engineers sometimes need to reshape the input image to a 1D vector to feed it to a dense neural network.

In this problem you are given a 2D matrix (image) and you must flatten the image to a 1D vector.

Sample Input:
<class 'list'>
img: [[1, 1, 1, 1], [0, 0, 0, 0]]

Expected Output:
<class 'numpy.ndarray'>
[1 1 1 1 0 0 0 0]

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Rerum quisquam accusamus consectetur sint temporibus et nostrum?

Vel adipisci provident eaque ratione quis et eos culpa perspiciatis, corporis sit aperiam autem in.

Eaque ipsum cupiditate recusandae, error molestias quae itaque provident neque, vitae rerum incidunt ratione quibusdam perspiciatis, veniam dolorum sapiente minima suscipit sed ipsum ex temporibus corporis id laudantium, nam excepturi aliquid dolore?

This is a premium feature.
To access this and other such features, click on upgrade below.

Ready.

Input Test Case

Please enter only one test case at a time
numpy has been already imported as np (import numpy as np)