25 items tagged
Motivation Julia is a very fast language. Julia hybrids many features from many sources. Here I’m taking note on its syntax and features by comparing to Python and Matlab. Basic Functions print is like in python BUT, no \n added at the end of each line. println has the \n String formatting is super easy, we can just use values of expressions. "$greet, $whom.\n" "1 + 2 = $(1 + 2)" Operators . operation extend its usage in matlab it means to vectorize sth. or broadcast one operation to all the element of the argument. This is super powerful, extending beyond arithmatics. You can broadcast everything by putting a . there. ... is like * in python, it could de-bundle a tuple or list into lots of variables. Types :: signify the type of sth. <: signify the type is a subtype of X. nothing equiv to None in python Similar to matlab true false not capitalized. Control Flow Control flow syntax is much like matlab if...elseif...end no indentation or :. Loop syntax is a bit like Python for .... in ..., with some caveat But if there are two things being looped, there needs to be a () , not like python. for (i,x) in enumerate(L) Functions Syntax is like
MTurk MTurk is a online way to recruit subjects and perform tasks, widely used in psychology and machine learning to collect human perception and behavior data. Some terminology: HIT: Basically the task Requester: the experimenter Worker: the subjects An work through of a task (Image classification)
Motivation Last we we are pushed to a weird domain, using MTurk to assess perceptual properties of some images. And the major technical challenge is to make a form like question page in MTurk, using my close to zero prior knowledge on JavaScript. Here are something I learnt along this. In this note I’m introducing a few key examples of using JavaScript to interact with HTML.
Motivation Writing a ML2 task with relatively complex timing dependency. https://monkeylogic.nimh.nih.gov/docs_CreatingTask.html#RuntimeVersion2 Adapter Chain child = Adapter1(tracker); parent = Adapter2(child); topmost = Adapter3(parent); scene = create_scene(topmost); run_scene(scene); This programming paradigm is really similar to that used in Tensorflow. The Adapters are like operator function on variables. But nothing really happen to the scene until run_scene
Note on Compiling Torch C Extensions Motivation Sometimes fusing operations in C library without using python can accelerate your model, especially for key operations that occurs a lot and lots of data pass through.
Environment Bug https://github.com/rosinality/stylegan2-pytorch/issues/70 Compiler not found bug We need to change compiler_bindir_search_path in ./stylegan2/dnnlib/tflib/custom_ops.pyNeed to be changed to have the C compiler on the machine. Note Visual Studio 2019 is not supported so have to use 2017!
Motivation This is a simple example. https://github.com/ProGamerGov/pytorch-old-tensorflow-models if pretrained: self.load_state_dict(torch.hub.load_state_dict_from_url(model_urls['inceptionv1'], progress=progress)) The official blog about how to use this is here. Hosting Weights The major challenge is to publish weight online. For that you need a public file hosting service, which Google Drive and OneDrive can do.
Motivation Sometimes, we want to manipulate and interact with our plot in a way that is not built into matlab figure. For example, we would like to visualize images when we are travelling in the hidden space. I requires matlab to visualize things when we click something or slide some bar.
Motivation This is one step forward from Data transport between python and matlab, since sometimes you not only want to transport data, but want to share some code in python or matlab. How can we do so?
Motivation Sometimes we are just too lazy to open a python script to do some file manipulation. (where it actually use the system api). Why not just use system’s scripting language?
Motivation Method Follow the link to install the add-on to blender https://github.com/eliemichel/MapsModelsImporter Install the RenderDoc program on windows, to inject process to Chrome to fetch 3d data from it. Create a shortcut to launch chrome with some additional debug flags Run chrome, record the process number, pause. Inject to that number in RenderDoc program Then start chrome and go to google map to your favorite buildings Capture through RenderDoc. Save to rdc files to disk. Load that rdc through Blender! and you have your 3d models! Post processing Join the patches to a single object. And merge vertices by distance。 Process texture and stuff to retain a single kind of material with the color. See the youtube video for a tutorial.
Motivation Common Formats Some formats are really common, so that python and matlab both have standard way to import, read and write. So these can be a common json, yaml Simple python dictionary could be easily dumped in yaml json formats, which record the hierachical structure and can store small amount of array data. The best part is it’s human readable. So it’s really suitable to store short configuration files.
Motivation Sometimes, animation is a great boost for a scientific idea in a paper. Though PDF is a old fashion communication media, we could add animation to it to give it some vigor. Method For small gif type short movie, using animate is a good choice. The syntax for using it is simple
Motivation Syntax highlighting for codes Procedurally adding lots of figures to slides using the same format (if you don’t want to copy paste in pptx) Adding lots of equations to it from latex format. Technical Choices Source of info
Motivation Handling parameter and recording them for numerical experiment is a pain in matlab. Solutions Option Parser Input the options as different fields of a structure and parse it through a function, fill in the fields that are missing by checking isfield
Motivation Matlab and matplotlib in python are plotting packages of daily usage. They share lots of structures but also have minor differences. For beginners using the plotting routines can suffice most daily needs, but for more refined control over layout, fontsize and so on, we need to better understand the object structure in matlab and matplotlib.
TOC {:toc} Deep Learning Environment Currently we find that multiple version of CUDA could be installed on windows. And different frameworks could use different CUDA version nicely together. PyTorch Tensorflow Co-environment Currently, we can have
Motivation pandas is a great tool for representing structured data in python, similar to Table in matlab and dataframe in R . Using it to interact with table data (like experimental records) on hard drive and process it in python is also great!
Motivation Unlike matlab, plotting dynamics in python is not as easy or straight forward to use. And to interact with the figure is not always as simple as matlab native plotting routines.
Computer Graphics environment in Matlab @(515.1 Computer Graphics)[matlab] Recently, we are using matlab to do computer vision experiments. Thus this note introduces some function controlling the elementary graphics environment. For Computer Graphics, the basic 3 components are
Multi-platform Matlab compiling When trying to compile a matlab code, I faced and solved many errors either on the Windows platform and the MacOS platform. Here I note some prominent difference across platform and how to debug the compiling process.
Installation Official note on installation https://caffe.berkeleyvision.org/installation.html Installing CPU version on CHPC Install Miniconda Install caffe using condaconda install -c intel caffe lsb_release -d Description: CentOS release 6.10 (Final) Building GPU version on CHPC (Not succeeded yet…. aborted)
TOC {:toc} Python is a script language. Most of the packages are written in python, and they are just a bunch of script files in a folder hierachy. For these packages, it’s just as easy as find the script file and run them.
Overview Objective: Build a online blog. Most preferably Posts can be written in Markdown, which is the format of most of my notes. Math formula (in Latex syntax) and equation rendering are Solution
Just like written languages, different programming languages have different innate styles, which suit different needs. Like Matlab love matrix, love script; python favors tensor, favors subfunction, favors objective-oriented programming; Mathematica are muchly functional; R are better at datatable demonstration.