Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function in Python (without using modules) that, given a M by N matrix and an integer k, if M by N matrix can

image text in transcribed

Write a function in Python (without using modules) that, given a M by N matrix and an integer k, if M by N matrix can be divided by the k by k square matrix, returns the sum of maximum value of each square matrix. If not, returns0 Input: M by N matrix and an integer k Output: Sum of maximum values of each subregion (each k by k square matrix within the M by N matrix) Visual Depiction: Given a 4x4 matrix 1 1 2 4 5 6 7 8 3 2 10 1 234 and a square window of size 2x2, the subregions are: 11|24 5 6 78 3 2| 10 1 2134 The corresponding Max Pooled values for each subregions are: 6 8 So output is the sum of the max values of each subregion is 6+8+3+421 Examples: Example 1 Input: ([[20, 200, -13, 1341, [120, 32, -120, 12]1, 2) Example 1 Output: 320 200 and 120 are max's of given 2 x 4 matrix's two 2 x 2 square matrices Example 2 Input: ([[20, 200, -13, 134], [120, 32, -120, 1211, 4) Example 2 Output: "NONE' 2 x 4 matrix cannot be divided by 4 x 4 square matrix Example 3 Input: (I1 1 2 41,15 67 8],13 2 1 0], [1 2 3 411,2) Example 3 Output: 21

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M. Kroenke

1st Edition

0130086509, 978-0130086501

More Books

Students also viewed these Databases questions