Skip to main content

Posts

Inheritance and Built-in function decorators (Class method and Static method)

 https://stackoverflow.com/a/34885285 # multi level inheritance class GrandFather:     def __init__(self, grandfathername):         self.grandfathername = grandfathername class Father(GrandFather):     def __init__(self, fathername, grandfathername):         self.fathername = fathername         super(Father, self).__init__(grandfathername) class Son(Father):     def __init__(self, sonname, fathername, grandfathername):         self.sonname = sonname         super(Son, self).__init__(fathername, grandfathername)          s = Son('SonName', 'FatherName', 'GrandfatherName') print(s.sonname, s.fathername, s.grandfathername) # multiple inheritance class Dad():     def __init__(self, dadname, **kw):         self.dadname = dadname         super(Dad, self).__init__(**kw) #important class ...

Python deeper

  Everything is an Object https://www.i-programmer.info/programming/python/11683-programmers-python-variables-objects-and-attributes.html https://www.edureka.co/blog/interview-questions/python-interview-questions/ namespaces are variable names. variables and functions are objects in python objects are instance of a class functions are first class objects - meaning they are objects like int, float, bool, list, string etc., they can be passed as arguments, assigned to a variable, returned from a function, etc. - https://www.youtube.com/watch?v=p8RU0JH2xb8 "When one says "everything is an object" (like in Python), does he indeed mean that "everything is first-class"?" : Yes - “First class” means you can operate on them in the usual manner. Most of the times, this just means you can pass these first-class citizens as arguments to functions, or return them from functions. https://stackoverflow.com/questions/245192 Python Variable Scope –Built-in, Global,  Enclo...

Deeper into Python value change inside functions

 https://www.dataquest.io/blog/tutorial-functions-modify-lists-dictionaries-python/ number_1 = 5 number_2 = 10 def multiply_and_add ( number_1 , number_2 ) : number_1 = number_1 * 10 number_2 = number_2 * 10 return number_1 + number_2 a_sum = multiply_and_add ( number_1 , number_2 ) print ( a_sum ) print ( number_1 ) print ( number_2 ) 150 5 10   number_1 and number_2 did not change although they were global variables. because python stores global and local variables at different memory locations   def add ( x: float , y: float ) -> float : return x+y this is syntax only. even if you pass strings it will work. initial_list = [ 1 , 2 , 3 ] def duplicate_last ( a_list ) : last_element = a_list [ - 1 ] a_list . append ( last_element ) return a_list new_list = duplicate_last ( a_list = initial_list ) print ( new_list ) print ( initial_list ) [1, 2, 3, 3] [1, 2, 3, 3] global value of initial_list was upda...

TF 1.13.1 Inference From Model Frozen in Python [Working]

 In Visual Studio 2017: Download contents from: https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-gpu-windows-x86_64-1.13.1.zip This has the prebuilt binaries for C - doesn't work for C++: We use the one with GPU support but you can download cpu only as well. We extract it in C:\libtensorflow-gpu-windows-x86_64-1.13.1 Then: Set Debug mode to x64 Then go to Project >> Properties and: In VC++ Directories add path: C:\libtensorflow-gpu-windows-x86_64-1.13.1 in Include Directories and Library Directories In Linker >> Input add: tensorflow.lib in Additional Dependencies By default the project creates cpp file, so go to Source Files and rename the main file to *.c For example: catdogtest.cpp to catdogtest.c If you get library missing error make sure you've added correct paths in VC++ Directories and Linker You should copy tensorflow.dll from C:\libtensorflow-gpu-windows-x86_64-1.13.1 to project source files directory and add it to source files by right...

Compile TF 1.13.1 with Bazel - Windows 10 - CPU [ Working ]

Bazel Version: 0.20.0 Python Version: 3.6.7 Visual Studio 2015 Setup Python, MYS2, Bazel, Visual Studio  See: https://algidus.blogspot.com/2022/05/compile-tf-1131-bazel-windows-10.html git clone --recursive https://github.com/tensorflow/tensorflow Good Guide: https://github.com/guikarist/tensorflow-windows-build-script - for idea but his powershell script didn't work Info: Make sure you run command prompt as admin Make sure you replace checksum of icu: For TF1.13.1, change the sha256 to 86b85fbf1b251d7a658de86ce5a0c8f34151027cc60b01e1b76f167379acf181 in file tensorflow/third_party/icu/workspace.bzl from e15ffd84606323cbad5515bf9ecdf8061cc3bf80fb883b9e6aa162e485aa9761 All Logs just in case: F:\_ML\tensorflow_windows_build_script\tensorflow-windows-build-script\source>python configure.py WARNING: The following rc files are no longer being read, please transfer their contents or import their path into one of the standard rc files: nul WARNING: Running Bazel server ne...