Submitted by ole72444 t3_yuafo2 in deeplearning
sckuzzle t1_iw9fe1i wrote
Reply to comment by HMasterSunday in Making a model predict on the basis of a particular value by ole72444
Writing "short" code isn't a always good thing. Yes your suggestion has less lines, but:
-
It takes ~6 times as long to run
-
It does not return the correct output (split does not take every nth value, but rather groups it into n groups)
I'm absolutely not claiming my code was optimized, but it did clearly show the steps required to calculate the necessary output, so it was easy to understand. Writing "short" code is much more difficult to understand what is happening, and often leads to a bug (as seen here). Also, depending on how you are doing it, it often takes longer to run (the way it was implemented requires it to do extra steps which aren't necessary).
HMasterSunday t1_iw9qr8l wrote
Interesting, I didn't try a test run to time both approaches, I'll do that more often. As per your other point though, my code does account for that already, the number of individual cuts is 1/4 of the length of the full array (len(input_array)/4) so it splits it up into arrays of length 4 anyways. That much I do know at least.
sckuzzle t1_iwaia67 wrote
> As per your other point though, my code does account for that already
You may try running it? It returns [3.0, 8.0, 12.0, 8.0]. The intended output is [False, False, True, False]. OP didn't ask for it to be split into groups of four, they asked for every fourth value to be taken.
Viewing a single comment thread. View all comments