[Chicago] ReLU's pythonic?

Michael Tamillow mikaeltamillow96 at gmail.com
Fri Feb 17 16:14:19 EST 2017


Thanks for the thoughts - definitely agree the function call is easier on
the eyes

On Fri, Feb 17, 2017 at 1:37 PM, John Cronan <kyle at pbx.org> wrote:

> On the performance aspect: you have discovered function call overhead.
>
> I don't think speed is the ultimate measure of "pythonic." I think
> readability is a better candidate. But, certainly constructs that performs
> worse than alternatives by more than just a constant factor are unlikely to
> be adopted as ideal pythonic forms.
>
> -JK
>
> On Fri, Feb 17, 2017 at 1:19 PM, Michael Tamillow <
> mikaeltamillow96 at gmail.com> wrote:
>
>> Hey groupies!
>>
>>
>> I am curious about what people consider more pythonic.
>>
>> The zen of python says:
>>
>>
>> "There should be one-- and preferably only one --obvious way to do it."
>>
>> And so, I've been reading about ReLUs recently in Neural Networks (Rectified Linear Units), which all give the equation:
>>
>> f(x) = max(0, x)
>>
>> But, whenever I see this I think:
>>
>> f(x) = 0 if x < 0 else x
>>
>> So I am wondering if there are any thoughts on what is more pythonic. The second way ran 4x as fast for me in python using the built in max function over 10,000 iterations. Which makes sense since the max function must do at least one comparison operation.
>>
>> Thoughts? Is speed the ultimate measure of what's pythonic? Or something else?
>>
>>
>> _______________________________________________
>> Chicago mailing list
>> Chicago at python.org
>> https://mail.python.org/mailman/listinfo/chicago
>>
>>
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> https://mail.python.org/mailman/listinfo/chicago
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20170217/4e2766ff/attachment.html>


More information about the Chicago mailing list