Sunday 13 May 2018

working on kaggle @TensorFlow Speech Recognition Challenge

Kaggle is the best place for machine learning ,data science and ai beginners to experts.
its really a cool place to learn and improve skills with others ..lot of people collaboratively working on real world problems.

Check out the link for tensorflow-speech-recognition-challenge 

Monday 5 March 2018

python if __name__ = '__main__':

What does the if __name__ == "__main__": do?

The global variable, __name__, in the module that is the entry point to your program, is '__main__'.
So, code in this if block will only run if that module is the entry point to your program.

Why do we need this?

Developing and Testing Your Code

Say you're writing a Python script designed to be used as a module:
def do_important():
    """This function does something very important"""
You could test the module by adding this call of the function to the bottom:
do_important()
and running it (on a command prompt) with something like:
~$ python important.py

The Problem

However, if you want to import the module to another script:
import important
On import, the do_important function would be called, so you'd probably comment out your call of the function at the bottom. And then you'll have to remember whether or not you've commented out your test function call. And this extra complexity would mean you're likely to forget, making your development process more troublesome.

A Better Way

The __name__ variable points to the namespace wherever the Python interpreter happens to be at the moment. Inside an imported module, it's the name of that module. But inside the primary module (or an interactive Python session, i.e. the interpreter's Read, Eval, Print Loop, or REPL) you are running everything from its "__main__".
So if you check before executing:
if __name__ == "__main__":
    do_important()
With the above, your code will only execute when you're running it as the primary module (or intentionally call it from another script).

An Even Better Way

There's a Pythonic way to improve on this, though.
What if we want to run this business process from outside the module? If we put the code we want to exercise as we develop and test in a function like this and then do our check for '__main__' immediately after:
def main():
    """business logic for when running this module as the primary one!"""
    setup()
    foo = do_important()
    bar = do_even_more_important(foo)
    for baz in bar:
        do_super_important(baz)
    teardown()

# Here's our payoff idiom!
if __name__ == '__main__':
    main()
We now have a final function for the end of our module that will run if we run the module as the primary module. It will allow the module and its functions and classes to be imported into other scripts without running the main function, and will also allow the module (and its functions and classes) to be called when running from a different '__main__' module, i.e.
import important
important.main()
This idiom can also be found in the Python documentation in an explanation of the __main__ module. That text states:
This module represents the (otherwise anonymous) scope in which the interpreter’s main program executes — commands read either from standard input, from a script file, or from an interactive prompt. It is this environment in which the idiomatic “conditional script” stanza causes a script to run:
if __name__ == '__main__':
    main()

Thursday 8 February 2018

Minergate signup

Get the most profit of your computer and smartphone. Automine coins with highest exchange rate. https://minergate.com/a/7ebf145cadc26a40daa62d2f

Wednesday 31 January 2018

Mg-giturl

https://raw.githubusercontent.com/sirivellamadhu/mg-script/master/mg-script.sh