« first day (2778 days earlier)      last day (2185 days later) » 

12:00 PM
well if I had given it any thought I could've realized I'm wrong. Which is exaclty what happened when I tracked down every remaining bug :)
 
I'm reading the docs of tensorflow, section on Notes on 'SAME' convolution padding - Tensorflow, which I'm trying to understand in which case the padding will become negative(I also posted this on Math.SE), any help will be appreciated.
 
I have a dict of 3d arrays and I was happy to take the dict -> 3d array -> subset of 3d array -> mutate 2d subparts, and I expected it to work :) Fortunately I had enough debug prints by then to see that it should work so clearly I was missing something obvious
 
Ok. That does sound potentially fragile. ;)
 
I would've gotten away with it if it weren't for those meddling kids fancy logical indices rather than slices
I even thought I tested this case by saving a backup of my original dict and comparing its inequality to the new one. I got "True" which is funny because I didn't even use a deepcopy
so I checked something completely different and wrong :D
wrong on a bit too many levels
 
Sam
12:26 PM
Hi guys I've got a side project where I've been implementing my own NN using Numpy. My aim is to recreate some of the most common used optimisers for learning purposes. If you look at my repo (in the Network.py), you can see that from the optimisers module I have imported my optimiser.. If I wanted to dynamically switch in and out which optimiser I wanted to use, how could I do this? I can only think to perform multiple conditional checks against some user inputted string
github.com/samjtozer/NumPy_NN/tree/optim-module. I think maybe the correct way to do this is to make an interface and derive each optimiser implementation as a class?
 
hmm?
what is it that you want to be able to do exactly?
Why not keep optimiser.opter1, optimiser.opter2 etc in its separate namespace and choose from among those based on input?
 
Sam
So inside the optimisers module, there's different algorithms implemented as functions. And if you look here: github.com/samjtozer/NumPy_NN/blob/optim-module/network.py#L99. this is where I call the optimiser.. I want to be able to switch in and out different optimisers without having to make a bulky if statement against some user inputted string (if possible)
 
dispatch dict?
optimisers = {'BGD': batch_gradient_descent}
then opt_key = 'BGD'; gradients = optimisers[opt_key](bundle)
 
Sam
Oh right OK that seems promising
Could you point me to the docs for this just so I could have a read through
 
There isn't documentation, per se, for dispatch dicts in the official documents. They aren't a fundamental part of the language, they're just something you can make when your language has dictionaries and functions as first class objects
 
12:34 PM
it's just a common pattern
 
Sam
Fair enough. Well that's a good solution, thanks Andras. And Kevin :)
 
no problem
 
Sam
12:49 PM
You able to confirm how the type of object the keys of optimisers would hold? I'm currently getting an AttributeError so I assume I'm doing something wrong :P
import optimisers
optim = {'BGD' : optimisers.batch_gradient_descent}
 
That code might raise an AttributeError if the optimisers module doesn't have a batch_gradient_descent variable.
I can see that you do have a function by that name in your repository, so probably the error is coming from somewhere else. Got a stack trace?
 
He didn't import optimisers I think
No, that'd be NameError
 
Sam
gist.github.com/samjtozer/a0b0809eb18718ef46eb91e2f1b32c30. I thought the following might of worked as its a function not a variable but get the same error.
optim = {'BGD' : optimisers.batch_gradient_descent(object)}
 
Optimiser vs optimisers?
I.e. plurals don't add up
I suspect you have module optimiser and optimiser="BGD"
I used a more creative key for this reason :P
> AttributeError: 'str' object has no attribute 'batch_gradient_descent'
the error says as much
If you're not willing to read it, at least paste the whole thing the first time
 
Sam
Ahh shoot you're right. It is clashing with a parameter from __init__, sorry guys x.x
 
12:58 PM
mrng cbg
 
Sam
@AndrasDeak paste the whole thing?
 
The error. Which you've eventually done
10 mins ago, by Sam
You able to confirm how the type of object the keys of optimisers would hold? I'm currently getting an AttributeError so I assume I'm doing something wrong :P
 
Sam
Ah right, you mean post the error log when asking the question? Got you
 
^ this seemed to have implied an attribute error on the module
 
Sam
But instead my carelessness
 
1:06 PM
Unrelated to the current conversation: is there any reason that docs.python.org/3/reference/… recommends object.__getattribute__(self, name) over super().__getattribute__(name)? Playing around with it for thirty seconds, both seem to work for my purposes
 
Doesn't the former always refer to the same thing while the latter refers to the latest parent class in the potentially long chain?
 
@Kevin super().__getattribute__ would definitely be better there
 
Yeah. When it says "its implementation should always call the base class method with the same name", I assume by "base class" it means "parent class"
The implication being that you should only call object.__getattribute__ if your object inherits from object
 
Then, idk, super seems better to me.
 
@piRSquared Yes, they technically don't do the same thing. But good reasons to hard-code the parent class instead of using super are very rare
 
1:11 PM
On the other hand, maybe "base class" really does mean object, and they want you to always call it in this way.
 
super seems like it would superlatively better.
 
Basically the design question comes down to: when implementing __getattribute__, if you need to actually access an attribute, is it preferable to ask the parent class for the attribute (and possibly get something that's not a real attribute, if the parent also implements __getattribute__), or is it preferable to ask the object class (and get something that is definitely a real attribute)?
 
^ that was my first impression
 
I'll just put both approaches in stackoverflow.com/questions/50529556/… and let OP decide
 
Except I didn't want to write it all down because I am not @abarnert and I cannot type faster than I can think.
 
1:16 PM
I'm a little worried about my solution there because if the dictionary happens to contain a "__class__" key, then bad things may happen.
 
Why would you want to bypass your parent class's mechanisms? Most of the time you don't even know if the attribute you're accessing is a real attribute or not, and you really shouldn't care. Just let the parent class do its thing :I
 
If you're overriding __getattribute__, you're probably already in violation of good OO design principles, so all bets are off :-P
 
Yeah, the easy fix would've been to just remove the ibute :P
(Which would of course change the class's behavior, but I'd argue that it would change in a good way)
 
\o cbg
To our southerly friends, happy Friday on your long weekend :D To our northerly and/or non American friends, happy Friday
 
Why do only the "southerly friends" get a long week-end ? :p
 
1:25 PM
take it up with your law makers I'm just trying to survive this heat
 
3:30pm here. The week-end is near. ;d
 
Hi @MooingRawr. It's almost Saturday here. I just wrote you a program. I'll put it in a gist.
 
Halfway through trying to write an implementation that checks for existing attributes first and returns values in the dict second, it occurs to me that that's exactly what __getattr__ is for. I wonder why OP reached for the more difficult-to-implement dunder to begin with.
Smart money's on "it's the first thing I found that looked like it would work"
 
The knight's tour thing? I only got as far was making my pieces move, I have yet to implement the BFS or some other solution
 
1:30 PM
oh nice, I'm currently working on one without a list of list to represent the board. I think it's more complicated than it needs to be but eh :D
 
@Niing the padding is never negative
 
morning cbg
 
@MooingRawr I nearly used a dict, so I could index it with tuples, but I decided to be more traditional and use a 2D list.
 
I see currently I'm reperesenting the board as x*y and i'm using validate_moves = {3,7,9,11,-3,-7,-9,-11}adjusting the values for the size of the board. I'm not sure it will work out but it works for 8x8 and 5x5
cbg idjaw
it would be a million time easier to represent the board as a traditional 2d list or some other structure base, but where's the fun in that :D
 
Any ansible folks here can direct me to where I can read about separation of responsibility when it comes to designing roles? I'm trying to formulate a best practice to better handle infra automation and I'm not sure some of the roles I'm using are designed optimally. I wonder if @KevinMGranger can give advice on that 😀
 
1:36 PM
however I do like how your solution gives me every combination of solution there is .... :\ I think that's pretty neat (unless the mass printing is doing each step but it doesn't seem like it for the first few print outs)
 
Even neater would be to make it a generator that yields boards, rather than printing them.
 
Representing a 2d board as a 1d array, and representing a 2d move as a 1d delta, is an interesting idea. But it seems like it would make boundary checking harder. Unless it's fine if the knight can jump off the left side of the board and land on the right side, pac man style.
 
If you want to get really tricky, make one that can find cyclic solutions, that is, the knight finishes on the starting square.
 
My first solution did that Kevin, when I tried to add edge guarding my code got super messy and wouldn't work :(
repl.it/repls/VitalHauntingConsulting I messed something up, alias I'm being pulled into another pointless meeting will be back in half an hour to pick up where I left off
 
DSM
1:52 PM
Friday morning cabbage for all!
 
cbg @DSM
 
Hi, DSM
 
whaddup @DSM
 
Hello everyone! I intended to write a program that computes a factorial:
def factorial(x):
while n>=1:
return x * n
n = n - 1
n = int(input())
print(x)
 
recbg
 
1:57 PM
when i type 4 it gives 5
 
@Tug'Tegin Welcome! Please read sopython.com/wiki/… for formatting code in chat
 
It looks like there's a return statement in your loop
 
@AndrasDeak Ok.
 
Unconditional return in a loop is generally wrong, since it means your loop only runs once. In other words, it doesn't loop.
 
thanks I am going to investigate it.
 
2:01 PM
It's hard to tell without seeing the code with its proper indentation, but I think there are other problems with that factorial function.
 
there's no increment nor recursion
 
n = n-1 decrements, provided it's inside the function. Although I'd expect that to give an UnboundLocalError, as-is
 
OK, I meant "accumulate"
so talking about a += someplace
 
Oh, gotcha. Yeah, a *= somewhere would be good.
 
oops, right, that
 
DSM
2:04 PM
(Don't mind me, I'm just un-starring answer-like comments.)
 
+= can work too if you do it n times...
 
Incidentally, I am curious why new users tend to use while and manual (in|de)crementing, rather than a regular old for loop. Are they afraid that range() takes up O(N) memory, or something?
 
@Neoares You're right, thank you. but i have another idea that a negative padding could mean that some information, i.e. pixels, are ignored, when s>k.
 
@DSM what if those answers are funny?
 
@Kevin or just coming from a different language where while may be more straightforward in syntax?
 
2:05 PM
@Kevin Probably a habit from whatever language they're coming from
 
@Niing ah.. I'm assuming S = stride and k = kernel size?
 
DSM
@piRSquared: they have to get at least a 4 on my arbitrary comedy scale.
 
Maybe they read about for loops, but didn't read about range, so they know you can iterate directly over a collection, but don't know that it's easy to make a collection of consecutive integers
 
Sounds fair
 
DSM
Sounds four. (Which would only get a 2.)
 
2:06 PM
:|
at least you defined a scale
assuming we agree on what is 0
 
Using decrement in factorial is ok, but I agree a range is more Pythonic.
def factorial(n):
    x = 1
    while n > 1:
        x *= n
        n -= 1
    return x
 
also, S can not be bigger than kernel size
or it doesn't make sense
yes, you're skipping pixels, but maybe you're more interested in applying a max-pooling after the convolutional layer
 
@Neoares yes, because it seems like the docs/api doesn't restrict that s<=k, but in my question on math.se i did make this assumption and that makes padding non-negative. i know what you meant
I'm agree with you so made the assumption s<=k in my question, but from the description it seems like it is not necessarily s<=k. Appreciate your time.
 
well the meeting ended short, I also found out my problem of falling into the pit of list and set being passed from function to function without using copy :\ repl.it/repls/VitalHauntingConsulting it works for a 5x5 now, but my 8x8 broke time to find out the validate path algorithm :\
 
Using range is Ok, but why not summon Zalgo into our plane with a little bit of lambda:
>>> (lambda f: lambda x: f(x,f))(lambda x,s: (1 if x == 0 else x * s(x-1,s)))(5)
120
I tried my hand at writing a knight's tour generator, but it yields only one result before terminating, so I guess I messed something up.
Also it takes five minutes to generate that one result.
 
2:12 PM
@Neoares from the docs, line 14 : 'Note that this might lead to negative , since in some cases we might already have more input samples than we actually need.', which lead to my question, but i'm agree that s<=k.
 
yeah I'm reading it
so your question is:
 
Here's another silly recursive one. But I'll give it a cache.
from functools import lru_cache
@lru_cache(None)
def f(n): return 1 if n < 2 else (n - 1) * (f(n-1) + f(n-2))
 
if s<=k, how can pi increase if ni increase?
 
pi is constant
 
lol
he meant p_i
 
2:17 PM
who do you mean by "he" ?
pi is the padding you apply
oh
@AndrasDeak didn't read that
 
OK:)
 
I don't understand what do they mean by "input samples"
 
@Neoares sorry maybe my example of pixels is misleading
I think they mean an entire graph an example
 
so, I think you have to assume that ni = no
because that's what "SAME" padding does
sorry, no = (ni/s)
 
@Neoares no sorry, the description of the docs is somehow vague. They should provide an (visualized) example.
 
2:32 PM
@Kevin Here's a generator one, but it's a bit ugly because you have to set the initial position manually.
def knight(cy, cx, n):
    if n > hinum:
        yield board
    else:
        for mx, my in moves:
            y, x = cy + my, cx + mx
            if 0 <= y < size and 0 <= x < size and not board[y][x]:
                board[y][x] = n
                yield from knight(y, x, n + 1)
                board[y][x] = 0
size = 5
hinum = size * size
board = [[0] * size for _ in range(size)]
cy, cx = 0, 0
board[cy][cx] = 1
for i, board in enumerate(knight(cy, cx, 2)):
    print(i, '\n'.join([' '.join([f'{u:>2}' for u in row])
            for row in board]), sep='\n', end='\n\n')
 
@Neoares if ni,no mean the number of input graphs then i'm agree with ni=no. the using of 'input samples' is vague.
 
ni is the size of the input and no the size of the output
 
I got my generator to work. It was only giving one result because I was doing print(next(knight())) :-P
 
:)
 
the interpreter acting up again, eh?
 
2:35 PM
Here is the implementation. Only marginally noteworthy because I don't have a "board" object per se, just a set of already-traveled spaces
 
uh, y before x...
you're evil, Kevin
 
If you don't like the ordering of my dimensions, feel free to change them around. The problem is the same irrespective of rotation and reflection, after all
 
def knight(cx, cy, n):
done
 
Oops, you edited PM's code and not mine. While my code has a permissive "edit what you like" license, PM's has a stricter "edit and then send me ten dollars" license. Gotta read those EULAs.
 
I like your style
 
2:43 PM
that explains why I couldn't understand his reference to Kevin's code
 
yield (curpos,) + result
why the comma
I've seen that many times
 
because you can only concatenate tuples with tuples
(curpos,) is a single-element tuple
(curpos) would just be curpos
sometimes you may omit the parentheses, but never the comma
 
so (tuple,) + tuple
and you get a (tuple, tuple)
instead of the concatenation of both
 
yes no
(anything,) + tuple
 
well, that
 
2:46 PM
but how should i pronounce it?
 
two-ple :P
 
'top'le or 'tu'ple?
 
not the former
 
Tupple
 
some people say it with a soft t as in Tudor
@Kevin nooooooo
 
2:46 PM
tweetple
 
DSM
tyou-PLAY.
Unfortunately Python didn't have good unicode support when tuples were introduced, so the accent was lost.
 
I have to maintain symmetry with my pronunciation of sextuple, septuple, etc etc
 
I said it like it'd be in spanish
 
@Neoares "etuple"?
 
like TOO
then PLE
well, actually in spanish is called "tupla"
 
2:48 PM
i like that
 
I don't think they have a name in my native language
we tend to give awful names to CS concepts anyway
 
it's more of a math concept, isn't it?
 
yes
it's an ordered list of things
 
isn't CS a subset of math?
 
>:(
 
2:50 PM
hm...
 
when i read something i didn't like, it must be related to math
 
no
 
Is that a frown from CS or from math?
 
Yes, the semantics of the tuple elements are determined by position, hence the usual advice that "tuples are for sequences of different things, lists are for sequences of the same things." However, that's only half the story.
 
eh, feigned puritism
 
2:51 PM
but from which side? :D
 
cs I guess
 
the dark one
 
I can't argue my way out of a paperbag when it comes to math
 
Since each element's position determines its "meaning," mathematicians are perfectly happy with it, because they've been using them like that for hundreds of years. In a program, however, this leads to obscure code, since numeric indexes ([i]) give little insight into the field that is being accessed. Hence the named tuple, where they are also accessible as attributes.
 
@Arne "the paperbag is topologically equivalent to a disk so I can't be inside it"
there you go, you're free
 
2:53 PM
you win
oh, it wasn't a trap?
 
>:(
 
how's a paperbag topologically equivalent to a disk?
 
how is it not?
 
@Neoares I did def knight(cy, cx, n=1) because that's the way 2D lists work. board[y][x] is the x column in the y row.
 
unless it has handles
 
2:54 PM
what's "topologically equivalent"?
 
well you should ask that first then
 
lol, this room is so math
i like it
 
@AndrasDeak I assumed it was the shape
 
topology is sort of the opposite of shape^[citation needed]
 
except you mean the bag is reversible, so it can be turned inside-out
 
2:55 PM
a mug and an American-style donut are topologically equivalent
 
> Topology is the mathematical study of the properties that are preserved through deformations
ooooooo
 
Short version: two shapes are topologically equivalent if you can mold one into the other without making any tears. Assuming you're working with an infinitely pliable material.
 
@AndrasDeak citation given
 
@Neoares smooth deformations
 
topology sounds like 'tuple'logy
 
DSM
2:56 PM
@Kevin: I read that as cry-tears, not rip-tears, which startled me. :-P
 
^
I was going to make an "I'm a big boy and I don't cry if I poke holes in my bag" pun
 
Crying is also forbidden in topology, but that doesn't come up as much at the introductory level
 
@AndrasDeak good thing you didn't, you would have opened yourself to all kinds of "and that's how he became a father" jokes
also weekend rbrb
 
see you
(assuming rbrb means bye)
 
lol
rbrb
 
3:03 PM
@_@
 
what's the meaning of stride on channel of an image
 
@Neoares Tes, it's a contraction of rhubarb per the salad specifications
 
isn't that the number of channel of image is always equal to that of a kernel?
 
Strides are usually the amount of memory addresses you need to jump when moving along a dimension in an array. Or something else that needs you to take every nth step
 
I like how ladies is "peaches"
@Niing the stride belongs to the convolutional layer
the stride is the offset when you apply the kernel to the input
instead of moving the kernel 1 by 1, you can skip an extra pixel with a stride of 2
so, by default the stride is 1
and the padding = "SAME" is used to keep the size of the output the same as the input's one
 
3:07 PM
@Neoares There's a song you might like: en.wikipedia.org/wiki/Peaches_%28The_Stranglers_song%29
 
I do like punk rock
how did you know?
 
i meant when using tf.nn.conv2d(), should the [3] of strides= always be 1?
since the reason i said above
 
@Neoares Just a guess... The song "Peaches" isn't very punk, though.
 
what is the [3] of strides? xD
is strides an array in your example?
 
cs way of describing thing
 
3:08 PM
the stride of a convolutional layer is an integer
it doesn't need to be one
 
@Neoares Here's an Aussie punk classic (I'm) Stranded by The Saints.
 
IIRC, the padding = "SAME" is to to apply the kernel even to the corners of the image
 
for example tf.nn.conv2d(img, filter, strides=[1,2,2,1], padding='SAME'), then I meant strides[3] should always be 1?
 
what.. lemme check the docs
I use keras, and in keras the stride is an integer
 
lol
maybe i should download keras too
 
3:11 PM
oh, you can apply strides for every dimension
nice
 
yes but then what's the meaning of stride on the channel dimension
 
well
don't think of the channel as the 3 rgb channels
 
isn't that the number of channel of img always the same as that of filter/kernel?
 
the channel size is the number of kernels you have in every layer
so, you can have 64 5x5 kernels
 
ok, but if they're not the same, then each output of a single filter/kernel will increase 1 dimension
 
3:13 PM
then the output will have a depth of 64
if you apply another layer to that, with a stride of 2 in the channel position (I guess the last one in the array), you will apply the kernel to only 32 of them
@Niing no, the dimension is always 4 (or 3 for grayscale images)
 
@Neoares ' you can have 64 5x5 kernels' but how about 64 of 5x5x3 kernels?
 
but the size of each dimension may vary
well, if you're working with RGB, the kernel is always NxMx3
but for visualization purposes, you usually omit it
multiplying an rgb image for a 5x5x3 kernel gives you a NxMx1 structure
so if you have 64 5x5x3 kernel, your output is NxMx64
then, the next convolutional layer you apply, will be 5x5x64 by default
times the number of kernels you want
you can apply 128 5x5x64 kernels
and the output will be NxMx128
 
@Neoares so if you have 64 5x5x3 kernel, your output is NxMx64 but this is based on the number of channel of img is the same as that of kernel.
 
that's why you usually omit that "3rd" dimension of the kernel, cause it's always the 3rd dimension of the input
well, the original image will have 3 channels usually
and the 64 is your choice
you can apply as many of them as you want
let me send you a nice tutorial for this
 
ok, so tensorflow generalize everything and it's possible of having 2-stride in channel dimension?
 
3:20 PM
I'm not sure about that, I've never work directly with tensorflow
as I said, in keras it's just an integer
so a stride of 4, in tf will be [1,4,4,1] I think
take a look at that course, specially week 1
you will understand everything
maybe you end up watching most of the videos 2 times, but it's very well explained
by the way
> data_format: An optional string from: "NHWC", "NCHW". Defaults to "NHWC". Specify the data format of the input and output data. With the default format "NHWC", the data is stored in the order of: [batch, height, width, channels]. Alternatively, the format could be "NCHW", the data storage order of: [batch, channels, height, width].
 
Do the PEP guidelines specify what import order should be used for private vs public imports? (ie: import tkinter vs import _tkinter)
 
@StevenVascellaro no, just let isort decide
 
Pylint and PyCharm keep trying to edit-war each other
 
Lazy solution: just don't ever import private modules.
 
Necromancer Cabbage
 
3:26 PM
@Kevin Under most circumstances I'd agree. However, functional testing tkinter requires it.
 
tell pycharm to STFU when it comes to import ordering ;)
 
@ThiefMaster Essentially, I'm not sure whether to file a bug report for PyCharm, PyLint, or both. :P
 
fwiw, it's mostly working OK and not contradicting isort, but sometimes it does... currently they end up doing backslash wrapping again for example instead of ()
the problem is that pycharm doesn't call isort (or pylint, if it can do reordering as well) but uses its own bad implementation
 
Next level lazy solution: don't do any testing
 
@ThiefMaster you could've said that 4 hours ago
 
3:30 PM
# pylint
import tkinter
import unittest.mock
import _tkinter

# pycharm
import _tkinter
import tkinter
import unittest.mock
 
DSM
@ThiefMaster: I'm beginning to think this is deliberate on your part, and it's really starting to annoy me.
 
Horrible solution: _tkinter = __import__("_tkinter")
 
KEVIN
 
@Kevin Worse solution: import _tkinter as tkinter
 
@Kevin wtf
it hurts
who offers more?
 
3:34 PM
pylint can't rearrange your imports if you don't have any import statements >:-)
 
still better than ctrl+f replace all
 
@DSM sorry, didn't think about it. it's the way i write and i tend to forget about the fact that you don't like it in here
 
DSM
@ThiefMaster: as we talked about the last several times this came up, this is a Meta policy, with the canonical answer by Jeff Atwood himself, and applies across the entire exchange. I shouldn't have to be repeatedly explaining this to someone whose name is in blue.
 
@Neoares how about no?
 
:(
 
I've warned you multiple times now, this is not the JS room. Cut the pointless noise.
 
I'm scared about making real noise
 
anyone need some music now?
 
3:55 PM
I'm listening to it
but I'm open to new suggestoins
 
@DSM and almost everyone else - including other mods - don't bother too much about enforcing language in chat, as long as it doesn't go into an excessive f-orgy. and I still strongly believe that there's a difference between using certain words towards some software, code style, etc vs using it against another human (which of course is something nobody should be doing)
 
I want to know who names a function tkinter.dooneevent()
 
agree to an EULA in order to view an online bug report, nice
 
3:59 PM
I just read that as tkinter.doonee_vent
 

« first day (2778 days earlier)      last day (2185 days later) »