• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

Programming |OT| C is better than C++! No, C++ is better than C

Somnid

Member
Have you a "state of the art" reference that deal with this topic? I'd really want to get up to date on this topic...

I keep using graphcuts, KNN, basic NN, etc., but I feel I miss something.

I stopped doing research some time ago, but I was toying with the idea of using NN to replace graphcuts on a classification project, and I never tried. I would love to correct this...

This is kinda a cool resource: https://www.youtube.com/user/keeroyz

Guy does 2 minute overviews of papers, mostly in graphics and ML.
 

Eridani

Member
I agree with all of that, my angle was that on ground terms, things that were known before year 2000 achieve pretty amazing results that are frighteningly close to state of the art considering how much progress happened since then. In terms of pure accuracy % gains I think that a majority of it comes from computational power. It's all about how you apply it to different problems, or how you push it to (slightly better) new state of the art that the research goes into from what I've been exposed to. Like, LSTM is still the best we can do for language modeling which is from 1997 (slightly better with variants), and it says something that you have to make something so out there and so complicated as an HM-LSTM to improve it by a tiny little bit more. AlphaGo is super impressive but to me the genius was how they were able to take such a complex variety of different algorithms and make them work together. I'll give you dropout, regularization solutions in general have done a lot recently (we can even count things like Nvidia's float16 craziness). Reinforcement learning is one thing that no amount of computation power could have helped in if it weren't for deep mind's recent progress, definitely.

I have a professor in my uni who takes it to the most extreme and says every single novel idea will eventually be made obsolete when we'll have enough computation power, haha. Dunno if I can buy that yet. His source of confidence is that he made a ton of money a couple of years ago when his startup made a classifier for files (malware/not malware) with no cyber knowledge, that performed better than the handcrafted cyber solutions (and I think even caught the NSA zero day exploits without being trained on it).

Yeah, it is pretty crazy how good even the relatively simple stuff works. However, pure accuracy gains aren't everything. One of the most interesting things for me is when people use neural networks in interesting ways, or in combination with other things. For example, this paper about modifying CNN to be used with varying input sizes for use in image segmentation and texture recognition, or this paper, which adapts word2vec to transform graphs into a low-dimensional vector form. Things like that won't just be solved by more power, and I'm really interested in what kind of crazy things people will come up with in the following years.
 

Koren

Member
Guy does 2 minute overviews of papers, mostly in graphics and ML.
Many, many thanks... Bookmarked for next month, when things will cool down...

Yeah, it is pretty crazy how good even the relatively simple stuff works.
Well, human brain works ;)

Things like that won't just be solved by more power
Depends on how many orders of magnitude we're talking, I'd say... Because of the above reason. We'll need a breakthrough in technology, though.

But otherwise, I agree, I often think the brute force is crude.
 
Hey guys, I have a questions about sanity checks. Reasonably broad question I suppose.

I guess I'm trying to figure out when to use them and when not to? When is a simple if statement to check a value or simply containing it in a unit test not enough?

I want to pinpoint the "right" use cases and also when I shouldn't use them.

Thanks in advance for any advice!
 
Hey guys, I have a questions about sanity checks. Reasonably broad question I suppose.

I guess I'm trying to figure out when to use them and when not to? When is a simple if statement to check a value or simply containing it in a unit test not enough?

I want to pinpoint the "right" use cases and also when I shouldn't use them.

Thanks in advance for any advice!

I like to use asserts wherever possible. Being able to make assumptions about input / output parameters drastically simplifies code and increases test coverage because tons of unexercised error handling paths that never get executed anyway get deleted.
 

Pixeluh

Member
Hmm, I have a question.

About two years ago I got really into web development as a hobby. I mainly focused on front-end and barely touched back-end technology. It made me want to pursue a career in CS.

However, after starting school I dropped the web development and focused on Python. This was because my programming class was based on Python so I focused only on that. Now that summer is open, I am wondering if I should continue with Python or go back to web development. I like them both the same. Web development was fun because you could see what you were building, unlike Python where everything has to be in the terminal. (I'm still in my first year of college and am learning how to problem solve, etc.)

Or should I maybe go out and try to learn C++? The school I am transferring to bases it's classes on C++, thus making my knowledge of Python semi useless. I have been told that learning C++ on your own is a bitch, and that learning it in a class environment is usually better.

So what are your opinions, focus on web development, python or c++? :)
 

Somnid

Member
Hmm, I have a question.

About two years ago I got really into web development as a hobby. I mainly focused on front-end and barely touched back-end technology. It made me want to pursue a career in CS.

However, after starting school I dropped the web development and focused on Python. This was because my programming class was based on Python so I focused only on that. Now that summer is open, I am wondering if I should continue with Python or go back to web development. I like them both the same. Web development was fun because you could see what you were building, unlike Python where everything has to be in the terminal. (I'm still in my first year of college and am learning how to problem solve, etc.)

Or should I maybe go out and try to learn C++? The school I am transferring to bases it's classes on C++, thus making my knowledge of Python semi useless. I have been told that learning C++ on your own is a bitch, and that learning it in a class environment is usually better.

So what are your opinions, focus on web development, python or c++? :)

Python + Web has a lot of versatility and you can use them both together. Not sure C++ would add much unless you really want to get into those types of jobs (embedded systems, game engines, performance critical applications). I'd just learn it as you go through classes.
 
web development w/ python. Look into flask w/ its default templating engine. Very lightweight and requires low cognitive load to get things up and running. Especially since you're just learning the basics, not having to eat an entire huge mature framework worth of docs and patterns will make things easier on you.

The reason I like python+web is that you learn skills by doing, and putting stuff on the web is an easily containable/doable project whereas a C++ project that you see from beginning to end is a good bit more (IMO) harder to conceptualize and deliver piece by piece.
 

Pixeluh

Member
web development w/ python. Look into flask w/ its default templating engine. Very lightweight and requires low cognitive load to get things up and running. Especially since you're just learning the basics, not having to eat an entire huge mature framework worth of docs and patterns will make things easier on you.

The reason I like python+web is that you learn skills by doing, and putting stuff on the web is an easily containable/doable project whereas a C++ project that you see from beginning to end is a good bit more (IMO) harder to conceptualize and deliver piece by piece.

I think I will try it out. Do you guys know of any websites to understand back-end better? I gave a shot learning Angular but my low knowledge of this stuff made it very difficult to understand. (This was 1+ year ago). I recall something about "MVC" of the sort? I'll probably stick to your suggesting at looking at flask.

I found back-end interesting but did not quite understand how people knew to set up the templates, url pages, data, etc.
 
I think I will try it out. Do you guys know of any websites to understand back-end better? I gave a shot learning Angular but my low knowledge of this stuff made it very difficult to understand. (This was 1+ year ago). I recall something about "MVC" of the sort? I'll probably stick to your suggesting at looking at flask.

I found back-end interesting but did not quite understand how people knew to set up the templates, url pages, data, etc.

the big part of mvc is model (the 'm') which is the data for your application. Since data is what makes applications interesting, the other two elements are about how to work with the data (controllers) or view the data (the view).

Personally I wouldn't worry about MVC. Just hack with Flask. Do something interesting and start using other features like an in-memory db and templating to render data out of the in-memory db.

Then watch a video for a conference on youtube from a flask expert at a conference, get your mind blown.
 
I second the recommendation for Python web development and starting out with Flask.

You will learn loads about MVC architecture, templates, routes, databases etc..

And Flask is a great micro framework. There are tons of tutorials online and youtube videos to learn from.
 

PantsuJo

Member
Python lover here, I can't get enough of it, I simply love the language.

Regarding this, I need an advice, GAF.

I need to create big (really big, each one 600Mb) XML files (generated with random data).

What is the fastest module for writing huge xml? Lxml? Better alternatives?
 

Pixeluh

Member
Well, I think I will come back to flask later on. I thought my python knowledge was okay but the flask code was quite hard to follow. I have no idea what decorators are since we skipped them in class, etc. I'll probably spend some time going over decorators, objects/classes in depth before trying flask again.

I was taught to use getters and setters in python but was told online that is not python like - what would I do instead then?
 

Eridani

Member
I was taught to use getters and setters in python but was told online that is not python like - what would I do instead then?

PEP 8, which is pretty much the most definitive python style guide has this to say on the topic:

For simple public data attributes, it is best to expose just the attribute name, without complicated accessor/mutator methods. Keep in mind that Python provides an easy path to future enhancement, should you find that a simple data attribute needs to grow functional behavior. In that case, use properties to hide functional implementation behind simple data attribute access syntax.

Note 1: Properties only work on new-style classes.

Note 2: Try to keep the functional behavior side-effect free, although side-effects such as caching are generally fine.

Note 3: Avoid using properties for computationally expensive operations; the attribute notation makes the caller believe that access is (relatively) cheap.

So basically, it's okay to just directly access simple attributes. Python doesn't really have private variables, so keeping everything private and using getters/setters isn't really something you have to do. Python libraries also don't use getters/setters, instead they just let you directly access the attributes

If you need to do some simple things to the data that would generally need a setter, then you use the @property annotator (since you said you want to go over decorators you might want to look at some tutorials covering this, since it ties in nicely). Or, if you can't be bothered with this, just make a method that does some more complicated stuff.
 

Koren

Member
Well, I think I will come back to flask later on. I thought my python knowledge was okay but the flask code was quite hard to follow. I have no idea what decorators are since we skipped them in class, etc.
Decorators are pretty simple if you have some basis in math... it's just function composition.

Quick'n dirty explanation...


For example, suppose you have a function
Code:
def f( x ) :
    ...

and another function
Code:
def g( foo ) :
   ...

When you write
Code:
def g(foo) :
    ....

...

@g
def f( x ) :
    ...

You basically write
Code:
def temporary_f( x ) :
    ... (code of f) ...

f = g( temporary_f )

so f actually means (g o _f) where _f is the function you've defined when you wrote def f( x ) : ...

It mostly make sense when g returns a function...

It's easier with an example. You probably know the Fibonacci function:
Code:
def fibo(n) :
    if n <= 0 :
        return 0
    if n == 1 :
        return 1
    return fibo(n-2) + fibo(n-1)

You know it's slow (try fibo(40) for example)

To understand why it's slow, define (before fibo)
Code:
def log(foo) :
    def bar(arg) :
        print("Call with argument", arg)
        return foo(arg)
    
    return bar

and add the @log decorator on the line before fibo :
Code:
@log
def fibo(n) :
    ...

Try fibo(10)... With only the decorator, you get all the informations on the calls (and you can decorate any fuction that takes a single argument this way)

Now, you want to speed up the function... Let's use memoization. Add another function before fibo
Code:
def memoize(foo) :
    mem = dict()
    
    def bar(arg) :
        try :
            return mem[arg]
        except KeyError :
            mem[arg] = foo(arg)
            return mem[arg]
    
    return bar

Now, add a second decorator:
Code:
@log
@memoize
def fibo(n) :
    ...

Now, try again fibo(40) or even fibo(100) and enjoy the magic...

Of course, it can be tricky to write decorator functions, especially if you're not into functional programming. But once you get the grip, it's terribly powerful.

That being said, there's ONE awful thing with Python decorators: it messes with the help string (you get the help string and the arguments of the decorator, not of the function). It's really, really bad for users. There's some awful tricks to preserve part of those data (there's a whole module for it) but it's far from perfect.


As I said, decorators usually return a function that call their argument (and do something else). But you can be nasty:

Code:
def blop(foo) :
    return False

@blop
def bar(x) :
    return True

Basically, in the above case, bar isn't even a function anymore, it's now the boolean False (the result of blop).


There's plently of functions in Python modules that are designed to act as decorators...


But yes, it worth the time studying a bit classes, special methods, decorators, etc. Feel free to ask for help here if you're stuck.


I was taught to use getters and setters in python but was told online that is not python like - what would I do instead then?
Directly use the attributes?

Who told you to use setters/getters? Most of the time, it's indeed unpythonic, and you won't get a lot of safety with those (since there's nothing private in Python).

If you need to do some value check, as Eridani said, @property is useful to create various kind of setters/getters, but you need a good reason to do this....

And please don't use __XXXXX to make something "private", even if you see it use elsewhere. There's no access control in Python like in other languages, the double leading underscore is used for name mangling, not to make objects private.

_XXXXX is sufficient to say to the user "You shouldn't use it". As some says, "we're all consenting adults here", and if people want to shot at their own feet, that's their problem, you did your job, no need to go extra mile and misuse something just to add a "protection" layer that actually won't prevent them to do something nasty if they want.
 

Koren

Member
On a completely different topic, I may have to dive back into NN sooner than I expected...


I may try to write an OCR for scanned handwritten characters... Segmentation should be semi-easy (one character per "box") but I'm out of practice for the classifier part.

Any suggestion about the structure of the network (number of stages, function, connexity)?

About the feature extraction (I've seen basically direct 7x5 scans after some preprocessing, and more elaborate with edge direction detection)?

Also, I haven't been able to find good training set for caps (I've found MNIST for digits, though)


The training set may not be the hardest part, once I've bootstrapped the thing, I'll probably be able to train it on a huge set for which I have some ground truth, although it could be tricky since I can't be sure I have perfect ground truth...


I'll look into it, but if anyone as good suggestions (since we talked about it last week!), those are welcome...
 
On a completely different topic, I may have to dive back into NN sooner than I expected...

Not exactly what you asked for, but I've been meaning to read this book as I've heard it's phenomenal and it comes highly recommended from some inside industry experts I've talked to. Also heard good things about this course.

Currently working my way through a bunch of linker and compiler books though, so I gotta finish all of these first.
 

HoodWinked

Member
Code:
class Console ():

  _name =''

  def __init__(self, name, price):
    self._name = name
    self.price = price
    
  def toString(self):
    return "{} costs {}".format(self._name, self.price)
    
  
class Handheld(Console):

  __battery = 0

  def __init__(self, name, price, battery):
    self.__battery = battery
    super(Handheld, self).__init__(name, price)

  def toString(self):
    return "{} costs {} with a {} mah battery".format(self._name, self.price, self.__battery)

cons = Console('xbox', 299)

print(cons.toString())

gameboy = Handheld('gameboy', 100, 1000)

print(gameboy.toString())

question about coding subclasses in python. followed a tutorial but it wouldnt run initially, had to change __name to _name for the subclass to be able to access the variable from the superclass. also another thing the price variable works even when i didnt inialize it like _name. whats the standard convention for naming variables in classes and subclasses? im using https://repl.it/languages/python3 to run the test code.
 

leroidys

Member
Code:
class Console ():

  _name =''

  def __init__(self, name, price):
    self._name = name
    self.price = price
    
  def toString(self):
    return "{} costs {}".format(self._name, self.price)
    
  
class Handheld(Console):

  __battery = 0

  def __init__(self, name, price, battery):
    self.__battery = battery
    super(Handheld, self).__init__(name, price)

  def toString(self):
    return "{} costs {} with a {} mah battery".format(self._name, self.price, self.__battery)

cons = Console('xbox', 299)

print(cons.toString())

gameboy = Handheld('gameboy', 100, 1000)

print(gameboy.toString())

question about coding subclasses in python. followed a tutorial but it wouldnt run initially, had to change __name to _name for the subclass to be able to access the variable from the superclass. also another thing the price variable works even when i didnt inialize it like _name. whats the standard convention for naming variables in classes and subclasses? im using https://repl.it/languages/python3 to run the test code.

You're not initializing _name, you're setting it as a class level variable. You don't want to be doing that in this case. As to the naming question, you're running into this https://en.wikipedia.org/wiki/Name_mangling#Python
 

Koren

Member
Not exactly what you asked for, but I've been meaning to read this book as I've heard it's phenomenal and it comes highly recommended from some inside industry experts I've talked to. Also heard good things about this course.

Currently working my way through a bunch of linker and compiler books though, so I gotta finish all of these first.
Many thinks, I'll try to find the book, and look into the course.

question about coding subclasses in python. followed a tutorial but it wouldnt run initially, had to change __name to _name for the subclass to be able to access the variable from the superclass. also another thing the price variable works even when i didnt inialize it like _name. whats the standard convention for naming variables in classes and subclasses? im using https://repl.it/languages/python3 to run the test code.
name for "public" attributes, you basically say the class user "use this if you want"
_name for internal usage, you say "don't use it, it's for internal purposes"

I'd say... don't use __name (and no, it's not "private", it's a trick using name mangling to hide the attribute, but it's not designed for this... It's used to avoid name collisions when subclassing, it gets replaced by _myclass__name, but it's no more hidden than _name)

As far as "initialization", it has been explained above... you have class attributes and instances attributes, they're for different purposes.
 
So as others have said, there are class variables and instance variables. You have made "_name" and "__battery" class variables.

What this means is that all instances share the same value. Where this is useful is as a random example if you had a "Car" class and in it you had a "count" class variable. Every time you create a new instance of "Car" you can say "count += 1".

So if you have instances car_A, car_B and car_C, in any of these instances you could return the "count" variable and it would be the same for each instance (3). This is because it is a variable associated with the class rather than the instance of the class.

If you added a 4th "Car" instance car_D, and then you return the value of "count" from within each instance, each one would return the value "4".

What you want to do in your classes is put the "self" keyword in front of those variables. That basically makes each instance tell Python "Hey, these variables belong to me and only me!".

This means that if you have car_A and car_B, if you change the "speed" instance variable in car_A to 50, then it will only affect car_A, car B will remain unchanged from whatever it's previous value was.

The second thing is your "toString" method, that is more of a Java-ish convention. In Python there is a special method that does the same thing: __str__ (double underscore)

So your code would then look like this:

Code:
class MyClass:

    def __init__(self):
        pass

    def __str__(self):
        return "Myself as a string"

As others have said, don't use __ in front of a variable, no variables in Python classes are private.
 

Koren

Member
Nice informative post... Just 2 cents...

What you want to do in your classes is put the "self" keyword in front of those variables. That basically makes each instance tell Python "Hey, these variables belong to me and only me!".
Beware, unlike other languages, "self" has no specific meaning. Python just pass the instance as the first argument of methods. Usually, you name the first argument "self", but it's a convention, you can give it any name. And sometimes, you may need this (when you create a class in an instance, and you want to be able to access both instances easily)

The second thing is your "toString" method, that is more of a Java-ish convention. In Python there is a special method that does the same thing: __str__ (double underscore)
There's also a __repr__ method. This is the one you should define if you only define one.

Both return a string. The result of __repr__ should be unambiguous (most of the time, you should be able to rebuild the object with the string... thus repr(1) and repr("1") give different results (they call __repr__) when str(1) and str("1") returns the same string.

__str__ is an alternative version if the result of __repr__ isn't easy to read (it should return a simpler string, with, for example, data missing)

if __str__ isn't available, it'll call __repr__, but the opposite is not true.

Worse, if you print a container, or use str() on a container, it'll call __repr__ methods on objects, so if __repr__ method isn't defined, you can't print a container with you class in it.

BTW, print() use __str__ but the interactive shell use __repr__


So, in short: go for __repr__


Edit:

An example if you define __repr__ only:
Code:
>>> class foo :
	def __repr__(self) :
	    return "bar"

	
>>> x = foo()
>>> x
bar
>>> print(x)
bar
>>> repr(x)
'bar'
>>> str(x)
'bar'
>>> (x,1)
(bar, 1)
>>> print( (x,1) )
(bar, 1)

An example if you define __str__ only:
Code:
>>> class foo :
	def __str__(self) :
	    return "bar"

	
>>> x = foo()
>>> x
<__main__.foo object at 0x7f8302b7c3c8>
>>> print(x)
bar
>>> repr(x)
'<__main__.foo object at 0x7f8302b7c3c8>'
>>> str(x)
'bar'
>>> (x,1)
(<__main__.foo object at 0x7f8302b7c3c8>, 1)
>>> print( (x,1) )
(<__main__.foo object at 0x7f8302b7c3c8>, 1)
 
That's what I like about this thread, everyone is really informative and it's a great learning resource, especially for new programmers or strange problems.

I was going to add in info about __repr__ and the fact that "self" is a convention but my fear was that I might overload the poster and make it seem too complicated but I think between all of the answers we've covered a good bit of info in a clear and concise way.

I don't know as much as a lot of the posters here but I'm glad to be able to contribute if I can. :)
 

Koren

Member
I was going to add in info about __repr__ and the fact that "self" is a convention but my fear was that I might overload the poster and make it seem too complicated
I hope you didn't mind... I thought about it, for the very same reasons. But I've been burned a couple times with __str__, so I though it might be useful to add an example...
 
I hope you didn't mind... I thought about it, for the very same reasons. But I've been burned a couple times with __str__, so I though it might be useful to add an example...

Oh no, not at all. Sorry if I came across wrong. I'm actually glad you posted it because it is useful to other posters who might not be aware and to be honest it's been a while since I even really thought about them in too much detail so it was good getting a refresher.

I hope I didn't come across passive aggressive or anything, I really do appreciate all the input, help and advice I get from this thread. I actually need to make an effort to post more often here but sometimes I get bogged down with work/life etc...

Getting back to programming I recently started looking into Docker and Docker-Compose, surprisingly easy to follow the basics once you get your head around it. For whatever reason I used to have a "fear of the unknown" with it.

Continuing to plow through a good book I have in Django too, I started a new job in IT and was traveling around for a bit so I haven't looked at much programming the last few months so I'm glad to be getting back into it.
 
Alright, who's ready to have their minds blown?

Are metaclasses coming to C++?

I'm skeptical. I think metaprogramming, in theory, is a net boon to the expressiveness of the language. For instance I like being able to auto-derive serialization from type definitions, and other reflective methods - these are not neat tricks, they're proper abstractions that deserve to be in serious languages. But I wasn't particularly impressed with the examples given. Interfaces are alright, but some of these example derivations didn't make any sense at all. Two dimensional points, for instance, can't be ordered at all don't admit a unique ordering, so why should a hypothetical value class derive instantiations for comparison operators?

The frontmatter said that this builds on 3 separate additions to the language. My question is, is it not possible to build class definitions programmatically using those proposals, specifically reflection and constexprs? I'm not really familiar with them.

I like that they're composable. And because C++ has multiple inheritance one doesn't have to worry about committing to any particular inheritance tree (i.e. I want something to be both a value metaclass and a ___, which doesn't derive from value).

Overall I don't know. History has not been kind to metaclasses. There was an entire book on Common Lisp's metaclass system and I was very impressed with it with childlike wonder when I first learned it but it certainly hasn't been influential to anyone but Ruby. (And I don't miss it myself). I think I would want to see more examples. The section on QT and WinRT are extremely promising but they don't show their proposed solutions. I trust them, but I want to see it! And I imagine other people would, too.
 

TheExodu5

Banned
Looking to create an online game with a friend.

Strategy, mostly text based with database updates triggered by the user when they adjust production values. Production ticks and majority of calculations would happen on the hour.

Thinking of learning node.js. Not sure if a full MEAN stack is appropriate, since the data model for the game makes it seem like it an object oriented approach would be more suitable.

Maybe node.js for user interaction and a python program for the hourly game tick? Don't know much about MongoDB, so not sure if it would be appropriate or if a relational DB would be better.

Thoughts? I'm primarily a Java developer so this will be new ground for me either way.
 

Koren

Member
If the game is simple enough, I would maybe go full Python (including web server)... But I'm biaised against Node.JS...
 
Anyone here use git for source control? I'm trying to merge my branch with an upstream one and I'm getting a lot of conflicts in unchanged files.

Edit:
Specifically GitHub
 

cheezcake

Member
Maybe a bit tangential to the point of this thread, but does anyone else here find the concept of a future driven by deep learning quite disappointing?

The technology is incredible, but the fact that when we 'solve' x problem by throwing a paired data set at a big black box and just watch the output til we get what we want and we call it a day.

It's sad right? We dont advance our understanding of the fundamental science or mathematics underlying the problem, it doesn't advance human knowledge in any form really. Maybe it's just an inevitability we've come to as we prod the limitations of the human brain, but that's a depressing realisation in itself.
 
Maybe a bit tangential to the point of this thread, but does anyone else here find the concept of a future driven by deep learning quite disappointing?

The technology is incredible, but the fact that when we 'solve' x problem by throwing a paired data set at a big black box and just watch the output til we get what we want and we call it a day.

It's sad right? We dont advance our understanding of the fundamental science or mathematics underlying the problem, it doesn't advance human knowledge in any form really. Maybe it's just an inevitability we've come to as we prod the limitations of the human brain, but that's a depressing realisation in itself.

I disagree entirely. Just look at AlphaGo for proof. Nobody knows what the fuck it's doing or how it's coming up with these moves, but when professionals study the moves after the fact they have had mny new insights, and new strategies are already developing among humans.

Humans often find themselves stuck in a local minima or maxima for a given problem's solution space. The mere act of the computer finding a completely novel solution leads us down new paths, and in turn greater understanding.
 
Use a merge tool or fix the conflicts yourself.

Well in this case a I just ran a grep on "gif status" and piped the changed files into a command that just accepted the upstream version.

But is it expected to get conflicts from a file that didn't change? I've never had this issue with Perforce.
 

Makai

Member
Well in this case a I just ran a grep on "gif status" and piped the changed files into a command that just accepted the upstream version.

But is it expected to get conflicts from a file that didn't change? I've never had this issue with Perforce.
You can see what the conflicts are and merge them. Might have been something like LF/CRLF or tabs/spaces if you don't see any changes.
 
You can see what the conflicts are and merge them. Might have been something like LF/CRLF or tabs/spaces if you don't see any changes.

Well there were a few cases of text being repeated. Another where a brace was moved like so:

Old:
If (blah)
{

New:
If (blah) {

I like the line ending suggestion, thanks. I'll double check that.
 
Well there were a few cases of text being repeated. Another where a brace was moved like so:

Old:
If (blah)
{

New:
If (blah) {

I like the line ending suggestion, thanks. I'll double check that.

You're probably using an IDE that auto formats your code when you open it. Don't do that.

Also, `git config --global core.autocrlf false`.
 

cheezcake

Member
I disagree entirely. Just look at AlphaGo for proof. Nobody knows what the fuck it's doing or how it's coming up with these moves, but when professionals study the moves after the fact they have had mny new insights, and new strategies are already developing among humans.

Humans often find themselves stuck in a local minima or maxima for a given problem's solution space. The mere act of the computer finding a completely novel solution leads us down new paths, and in turn greater understanding.

AlphaGo is relatively trivial in terms of trying to tie it's outputs to a more fundamental 'strategy' which gave birth to them. Fields like object recognition or image-to-image mapping have a much more difficult path in trying to decipher what the fuck the network has come up with. Of course the entire argument could be redundant in that simply having a machine capable of spitting out valid output is more valuable as a learning mechanism than having nothing, in which case it shifts to more of a problem regarding cultural attitude towards machine learning. Do we just stay content with the black box doing the right thing, or do we encourage a focus on reverse engineering the network to try and find get a more fundamental understanding of what's happening?

Anyway I'm literally just spitballing out loud, it's a thought I had this morning.
 
You're probably using an IDE that auto formats your code when you open it. Don't do that.

Also, `git config --global core.autocrlf false`.

Thanks. I think that config looks promising.

I've never opened the files in question in my IDE, but we do have a process we run which may have touched them.
 

Makai

Member
Why are these not equivalent? Replacing boolean with break.

Code:
let mut done = false;

for i in 0..expressions.len() {
    let mut expression = Box::new(expressions[i].clone());

    while !done {
        match expression.evaluate(&gamepad) {
            None => {
                use super::Expression::*;

                match *expression {
                    Stay(time) => {
                        self.time += time;

                        if self.time < 1.0 {
                            done = true;
                        } else {
                            self.time -= 1.0;
                        }
                    }
                    Loop(time) => {
                        self.time += time;

                        if self.time < 1.0 {
                            done = true;
                        } else {
                            self.time -= 1.0;
                        }
                    }
                    Change(next_state) => {
                        self.state = next_state;
                        self.time = 0.0;
                        done = true;
                    }
                    _ => done = true,
                }

                break;
            }
            Some(condition) => {
                expression = condition;
            }
        }
    }
}

Code:
for i in 0..expressions.len() {
    let mut expression = Box::new(expressions[i].clone());

    loop {
        match expression.evaluate(&gamepad) {
            None => {
                use super::Expression::*;

                match *expression {
                    Stay(time) => {
                        self.time += time;

                        if self.time < 1.0 {
                            break;
                        } else {
                            self.time -= 1.0;
                        }
                    }
                    Loop(time) => {
                        self.time += time;

                        if self.time < 1.0 {
                            break;
                        } else {
                            self.time -= 1.0;
                        }
                    }
                    Change(next_state) => {
                        self.state = next_state;
                        self.time = 0.0;
                        break;
                    }
                    _ => break,
                }

                break;
            }
            Some(condition) => {
                expression = condition;
            }
        }
    }
}
 
Because break only breaks the innermost loop and then continues the outermost loop, re-entering the innermost loop on the next iteration of the outermost loop.

In the boolean example, the value of done persists across invocations of the outermost loop, so as soon as done becomes true, the in innermost loop will never get re-entered

Move the declaration of the boolean inside the for loop
 

Makai

Member
Because break only breaks the innermost loop and then continues the outermost loop, re-entering the innermost loop on the next iteration of the outermost loop.

In the boolean example, the value of done persists across invocations of the outermost loop, so as soon as done becomes true, the in innermost loop will never get re-entered

Move the declaration of the boolean inside the for loop
Yep, thanks. I used a label to break at the outer scope. First version was the working one.
 
Yep, thanks. I used a label to break at the outer scope. First version was the working one.

The first version is also not equivalent to breaking the outermost loop, btw, since it runs every iteration which could be arbitrarily many computations for no reaso, and in theory the variable declaration on the first line could even modify state. So yea, label breaking is definitely an improvement
 

Makai

Member
btw this is part of the first interpreter I've ever written. Very simple programming language for game scripting - doesn't even have variables or functions. Feels cool seeing it work and I have a better appreciation for why JS uses hashtables for everything.
 

Koren

Member
Practical question for SQL gurus...

If I want to create a SQL database that holds data for documents, each related to a set of keywords/tags:

doc1 : wordA, wordC, wordZ
doc2 : wordA, wordB
doc3 : wordC, wordY, wordZ

And that I want to efficiently retrieve documents based on keywords:
- list documents that have all the keywords on the list
- possibly list documents that have all the keywords on the list minus one

Is this structure :
* table document: ID, full data on document
* table keyword: ID, keyword name
* table ref: ID_of_document, ID_of_keyword
the sanest solution?

And what would be the most efficient strategy to retrieve the documents using the keywords? A series of requests that narrow the search using one keyword at a time, or a single request using a join trick? Should I index something (keywords in table ref, I'd say, but...)?

(I suck at SQL efficiency :/ )
 
Practical question for SQL gurus...

If I want to create a SQL database that holds data for documents, each related to a set of keywords/tags:

doc1 : wordA, wordC, wordZ
doc2 : wordA, wordB
doc3 : wordC, wordY, wordZ

And that I want to efficiently retrieve documents based on keywords:
- list documents that have all the keywords on the list
- possibly list documents that have all the keywords on the list minus one

Is this structure :
* table document: ID, full data on document
* table keyword: ID, keyword name
* table ref: ID_of_document, ID_of_keyword
the sanest solution?

And what would be the most efficient strategy to retrieve the documents using the keywords? A series of requests that narrow the search using one keyword at a time, or a single request using a join trick? Should I index something (keywords in table ref, I'd say, but...)?

(I suck at SQL efficiency :/ )

What database are you using? For instance, with PostgreSQL there's also the possibility of storing the keywords/tags as a string array (VARCHAR[]) on the document table directly. I read a performance comparison (for PostgreSQL) not too long ago because I had the same problem: http://www.databasesoup.com/2015/01/tag-all-things.html
 

Eridani

Member
Maybe a bit tangential to the point of this thread, but does anyone else here find the concept of a future driven by deep learning quite disappointing?

The technology is incredible, but the fact that when we 'solve' x problem by throwing a paired data set at a big black box and just watch the output til we get what we want and we call it a day.

It's sad right? We dont advance our understanding of the fundamental science or mathematics underlying the problem, it doesn't advance human knowledge in any form really. Maybe it's just an inevitability we've come to as we prod the limitations of the human brain, but that's a depressing realisation in itself.

Neural networks aren't really some black box that we don't understand though. The math behind them is actually not all that complicated, and not all that different from other machine learning approaches. It can't be called a black box when we understand exactly how it works. We're also using our knowledge of how they work to constantly improve deep learning approaches, and to use them in combination with other things to achieve amazing results.

It's true that the output returned by neural networks isn't easy to understand, but that's by design really. You mentioned object recognition specifically, so let's look at that - or more generally, image classification. One of the most basic strategies that can be used to solve this problem is to manually come up with simple filters that describe your classes well and using them to classify images. It's an approach that is used quite a bit in several fields. With convolutional neural networks you're just taking out the manual part and using an error optimization function to automatically create filters that you know will work well in separating your classes. I don't see what's sad about that - it's obviously impossible to manually come up with filters that could classify every type of image (or recognize every type of object), and we're never going to find some underlying math behind that either (and if we are, deep learning is one of the better ways we have of doing that).

I also don't know why you're under the impression people aren't trying to understand results returned by deep neural networks. Here's a paper about visualizing convolutional neural networks to better understand the results they come up with. It is currently cited by 2035 other papers, which is quite a significant number.

The amount of research going into deep learning right now is also pretty staggering, mostly because just throwing some data into a neural network is very often not going to be enough.
 
Top Bottom