Note: Cycle GAN

We have set $X=\{x_1,x_2..\}$, $Y=\{y_1,_y2…\}$, where although there do not exist a one-to-one mapping between set $X,Y$, an element $x\in X$ is not distinguishable to elements in $Y$ if not for a certain consistent type of difference. (Eg. with/without snow, zebra/horse…)

Goal:

Find mappings $X \rightarrow X’, Y \rightarrow Y’$ so that $x’\in X’$ is similar enough to $x \in X$ but at the same time indistinguishable from $y\in Y$, and $y’\in Y’$ is similar enough to $y \in Y$ but at the same time indistinguishable from $x\in X$

Method:

Create two generators:
$$X’ =Gen_1(X) $$
$$Y’ = Gen_2(Y)$$
Create three losses:
$$L_{discriminator1}=disc(\{y’\},\{y\})$$
$$L_{discriminator2}=disc(\{x’\},\{x\})$$
$$L_{reconstruction}=||x-x’||_2+||y-y’||_2$$

And that is all that is necessary.
How amazing the design…

reference:

  • Unpaired Image-to-Image Translation
    using Cycle-Consistent Adversarial Networks

Note: Deep Learning and the Information Bottleneck Principle

Method:
For every layer’s output in a densely connected net, calculate its mutual information with the input $X$ and output $Y$.

Plot the two mutual information of each layer against each other. Observe change as the model is being trained.

NOTE: This network have exactly 12 bits of input and 2 bits of output.

Before training:
As a matter of fact, we observe the input layer(green) tells everything about the input itself, and almost everything about the output itself. Since all weights are randomly initialized, as the network goes deeper (further left bottom to the graph), less mutual information are contained against both $X$ and $Y$.

After training:
The layer outputs contains less information about the input, but more about the output.

What is important: The Middle:

Looking at a graph of how each layer moves along the training process, two distinct phases could be found, where in the first phase the layer contains more information of $Y$, where training error decreases. This phase happens fast. The second phase, taking most of the epoches, is a process of eliminating information of $X$ from the layer output. It is viewed as the process of generalization.


reference:
https://www.youtube.com/watch?v=EQTtBRM0sIs

Note: A Neural Algorithm of Artistic Style

[A Neural Algorithm of Artistic Style] presented an interesting way to disentangle style of a picture from content of a picture.

Using the convolution layers of VGG-Network trained for classification, both styles and contents of images could already be well extracted.

Def 1:
Define two image have the same content if they have the same filter response at every layer.

In short:
$$Loss_{def1}(img_1,img_2)=\sum_{l=0}^n{||F_{img_1}^l-F_{img_2}^l||_2}$$

where $F_{img}^l$ is the feature maps of $img$ at $l^{th}$ layer.

Def 2:
Define two image have same style if they have the same matrix of correlation among filter responses at every layer

  • Why define styles like this? Simple to remove spatial properties?
    In short:

$$Loss_{def2}(img1,img2) = \sum_{n=1}^l{||corr(F_{img_1}^l)- corr(F_{img_2}^l)||_2}$$

Goal:
Find an image $X_{gen}$ that minimize $loss_{def1}(X_{content}, X_{gen})$ using the gradient desent where $X_{content}$ be the image providing layout of the result and $X_{gen}$ be the resultant image starting from white noise.
At the same time, $X_{gen}$ need to minimize $loss_{def1}(X_{style}, X_{gen})$, where now $X_{style}$ is the image of a painting of some sort used to provide only style.

Let $X_{gen}$ be our final generated image.

  • Why use white noise?

Reference


2015

  • A Neural Algorithm of Artistic Style

    Gatys, L.~A. and Ecker, A.~S. and Bethge, M.



    2015




    [bibtex]




  • Fix Xlib: extension GLX missing on display :8 error running Gui programs

    After installing both Bumblebee and Nvdia Prime like this, an error of:

    1
    Xlib: extension "GLX" missing on display ":8".

    is got when attempting to run an gui program.

    The most effective solution found is to follow this solution here given by sapjunior, but with slight modification.

    Here’s the solution worked for me:
    Still all the driver version numbers need to be replaced with yours!

    1. Add the following to /etc/modprobe.d/bumblebee.conf

      1
      2
      3
      4
      alias nvidia-drm nvidia_364_drm
      alias nvidia-uvm nvidia_364_uvm
      alias nvidia-modeset nvidia_364_modeset
      remove nvidia rmmod nvidia-drm nvidia-modeset nvidia-uvm nvidia
    2. Perform these two command and record the configuration file names currently used.

      1
      2
      sudo update-alternatives --config x86_64-linux-gnu_gl_conf
      sudo update-alternatives --config i386-linux-gnu_gl_conf
    3. Make sure the x86_64 config contains all of the following

      1
      2
      3
      4
      5
      6
      /usr/lib/x86_64-linux-gnu/mesa
      /usr/lib/x86_64-linux-gnu/mesa-egl
      /usr/lib/i386-linux-gnu/mesa
      /usr/lib/i386-linux-gnu/mesa-egl
      /usr/lib/nvidia-387
      /usr/lib32/nvidia-387

      and the i386 config contains all of the following:

      1
      2
      /usr/lib/i386-linux-gnu/mesa
      /usr/lib32/nvidia-387
    4. Refresh shared libiary status with sudo ldconfig. (Maybe reboot just in case)

    2018/1/10

    Ubuntu 16.04 ultimate dual graphic card solution with newest nvidia proprietary drivers switchable without logout

    Finally I got it working. Using both nvidia-prime and bumblebee at the same time to allow switches between the two graphic cards (intel and nvidia) in both per-application-without-logout and whole-system-with-logout manner. My cuda also stays working at both mode.

    The following are the steps.

    1. Add newest nvidia-driver ppa: sudo add-apt-repository ppa:graphics-drivers/ppa;sudo apt update.

    2. Install the proprietary driver(in my case, 384, larger index should means newer) and nvidia-prime: sudo apt install nvidia-384 nvidia-prime.

    3. [optional] Add prime-indicator ppa and install sudo add-apt-repository ppa:nilarimogard/webupd8;sudo apt update;sudo apt install prime-indicator-plus;

    4. Reboot and the graphic cards should be able to be switchable with the indicator or x-org-setting from the dash menu. But it requires a reboot to perform the switch. If that’s not satisfactory and the user want more flexible control, proceed. If not, stop here.

    5. Install bbswitch and bumblebee: sudo apt install bbswitch-dkms bumblebee bumblebee-nvidia.

    6. Configure bumblebee to work.

      1
      2
      sudo gpasswd -a $USER bumblebee
      sudo systemctl enable bumblebeed

    open the config file sudo gedit /etc/bumblebee/bumblebee.conf and edit:
    Driver= $\rightarrow$ Driver=nvidia
    Remember to replace all 384 to your driver index
    KernelDriver=nvidia-384
    LibraryPath=/usr/lib/nvidia-384:/usr/lib32/nvidia-384
    XorgModulePath=/usr/lib/nvidia-384/xorg,/usr/lib/xorg/modules

    open the config file /etc/modprobe.d/bumblebee.conf and add:

    1
    2
    3
    blacklist nvidia-384
    blacklist nvidia-384-updates
    blacklist nvidia-experimental-384

    1. Reboot and prey.

    2. If everything goes right, you should be able to use optirun COMMAND to run an application using the nvidia graphic card even if you disabled the card and set to use the intel graphic card in the nvidia-prime setting.

    3. Try optirun COMMAND or primusrun COMMAND and see if everything works. It’s said that the former is of better performances but its actually 3 times slower on my machine.

    4. Remember to turn off the power of nvidia GPU after using it through the indicator to save power.

    2017/12/10

    Add: After updating to nvidia-387, except changing the config files, a manual power on through prime indicator seems to be necessary everytime before use.

    Add: To solve the error: Xlib: extension "GLX" missing on display ":8"., see here.

    Solution to AttributeError ProgressBar object has no attribute finished error using ubuntu-make

    It seems like the umake version contained in the ubuntu 16.04 ppa ppa:ubuntu-desktop/ubuntu-make breaks due to a change in the API of the python ProgressBar module…

    The error log looks like this:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    N/A% (0 of 100) | | Elapsed Time: 0:00:00 ETA: --:--:--Downloading and installing requirements
    ERROR: Unhandled exception
    Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/umake/tools.py", line 158, in wrapper
    function(*args, **kwargs)
    File "/usr/lib/python3/dist-packages/umake/frameworks/baseinstaller.py", line 288, in get_progress
    if not self.pbar.finished: # drawing is delayed, so ensure we are not done first
    AttributeError: 'ProgressBar' object has no attribute 'finished'
    ERROR: Unhandled exception
    Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/umake/tools.py", line 158, in wrapper
    function(*args, **kwargs)
    File "/usr/lib/python3/dist-packages/umake/frameworks/baseinstaller.py", line 288, in get_progress
    if not self.pbar.finished: # drawing is delayed, so ensure we are not done first
    AttributeError: 'ProgressBar' object has no attribute 'finished'

    However, I failed to find a file corresponding to File "/usr/lib/python3/dist-packages/umake/frameworks/baseinstaller.py" in the github repo, thus failing to start an pr/issue.

    For those who encounter similar issue, here’s the quick fix…

    1. Use your favorite editor and root access to open the file /usr/lib/python3/dist-packages/umake/frameworks/baseinstaller.py, e.g sudo gedit /usr/lib/python3/dist-packages/umake/frameworks/baseinstaller.py.

    2. Go to line 288.

    3. Change the line if not self.pbar.finished: # drawing is delayed, so ensure we are not done first to if True:, save and quit.

    4. The progress bar may looks kinda broken after the fix, but will have no interruption to any installation…

    2017/11/30

    Setting up the FRC development environment on ubuntu 16.04

    This is a record setting up the FRC development environment for C++/Java for the comp in 2018.

    1. Normally setting up the system, install anything one may need like git/svn/browser… and so on.

    2. Add FRC cmake tool ppa: sudo add-apt-repository ppa:wpilib/toolchain-beta, download package list: sudo apt update, download toolchains sudo apt install frc-toolchain.

    3. Download eclipse sudo apt install eclipse.

    4. Download C++ support for eclipse sudo apt install sudo apt install eclipse-cdt* if using bash(default). If using zsh, use sudo apt install eclipse-cdt\*.

    5. Install the IDE/editor wanted. In my case:

    1
    2
    3
    4
    5
    sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make;
    sudo add-apt-repository ppa:jonathonf/vim;
    sudo apt update;
    sudo apt install ubuntu-make vim;
    umake ide eclipse

    If umake went wrong(which suppose to in my current version), refer this link to fix a bug of umake

    1. Open eclipse and install the CDT plugin(for cpp development), Lib for FRC, and vim mode.
      help->install new software->add->Enter "http://download.eclipse.org/tools/cdt/releases/9.3" for eclipse oxygen -> select all -> install...
      help->install new software->add->Enter " http://vrapper.sourceforge.net/update-site/stable" for eclipse oxygen -> select all -> install...
      help->install new software->add->Enter " http://first.wpi.edu/FRC/roborio/release/eclipse/" for eclipse oxygen -> select all -> install...

    2. Install LabView started with downloading the standard linux ISO at the official website of NI.

    3. Unluckily, the official one only support redhat series thus our debian series will not fit. We need to convert those .rpm packages inside the ISO into .deb so we can install and manage them with our native package manager. (Although one can manually unpack and install them, it would be a great pain…)

    4. Start by installing tools: sudo apt install fakeroot alien.

    5. Then extract or mount the file inside the ISO and copy everything in the root dir (inside the i386 folder for 32 bit installations) to a any working directory.

    6. Run fakeroot alien -k --script ./*.rpm after entering the working directory chosen.

    7. Wait till finish, and sudo dpkg -i *.deb. And LabView should be installed.

    8. Now we need to install the FRC Plugin for LabView.

    9. Unfortunately, the current version of FRC Plugin does not support Linux OS…Tooooooooooo bad.

    10. Anyway, download the newest version of the zip file that could be found here; then unpack it into ~/wpilib/simulation. *(If not exist, create one.)

    11. Manually install the files:

      1
      2
      3
      4
      5
      vim sim_ds.desktop frcsim.desktop # Replace "/usr/bin" with "~/.local/bin"
      cd ~/wpilib/simulation/
      ln -s frcsim ~/.local/bin/
      ln -s sim_ds ~/.local/bin/sim_ds
      cp frcsim.desktop sim_ds.desktop ~/.local/share/applications/
    12. Build simulation for wpilib:

      
      

    2017/12/4 TO BE CONTINUED

    Make touchegg work on ubuntu unity/gnome desktops

    It seems like the unity DE somehow blocks the mouse gesture for itself, thus most of the other multi-touch recognizers can not catch the events.

    To disable this, the unity multi-touch support need to be completely disabled:

    1. Install dconf-editor, using apt install dconf-editor -y.
    2. Launch dconf-editor via command line.
    3. Go to com->canonical->unity->gestures and disable everything inside.

    Now tools like toughegg could catch touchpad events as normal.

    2017/11/23

    A Brief Summary of the Godel's Incompleteness Theorems

    $\forall Axiomatic_System \\=> (!Completeness) OR (!Consistency)$

    There are inherent limitations of every formal axiomatic system containing basic arithmetic.


    Completeness:

    for any statement in the axioms’ language, that statement or its negation is provable from the axioms

    Consistency:

    there is no statement such that both the statement and its negation are provable from the axioms

    First incompleteness theorem:

    The conclusion is: there will always be elements whether

    • both belong and don’t belong to a set => Breaking consistancy.
    • can not be classified => Breaking the completeness.

    Any consistent formal system F within which a certain amount of elementary arithmetic can be carried out is incomplete; i.e., there are statements of the language of F which can neither be proved nor disproved in F.

    Gödel sentence => The above mentioned statements that either unprovable or could be proved to be both true/false.

    • The Gödel sentence is designed to refer, indirectly, to itself.
    • Define itself as something that’s not itself in itself.
    • Construction:

      • $T \leftrightarrow \lnot True(T)$
    • With inconsistency $B\lor\lnot B$, we can prove anything:

      • $B\lor\lnot B$
      • $def: \lnot A \rightarrow (B \lor \lnot B)$
      • $\lnot(B\lor \neg B)\rightarrow \neg \neg A$
      • $B \land \neg B \rightarrow A$
      • $B \land \neg B$

    Second incompleteness theorem:

    Solution:

    The Type Theory, Where operators are put into types and they can not be used to describle those that are in the same type, including themselves. This way, the Russell Paradox, using an operation in a statement pointing to the statment itself as a Godel sentence, is simply invalid.

    Reference: Wikipedia, Zhihu1, Zhihu2

    2017/11/21

    Preventing CPU/IO Intensive Programs Blocking Linux Gui

    What for?

    The fact that the linux kernel does NOT come with a GUI and the GUIs used are third party components, their default priority levels (or nice level, which is user-space name for priority.) are the same as any other user space programs. This may cause the GUI to freeze when performing CPU/IO intensive jobs since they all run at the same priority level.

    What’s nice value/priority?

    To prevent that, we need to change the nice level, where the priority of a process equals NICE_VALUE+20. That’s said, higher priority level, same as higher nice level, creates a less prior job.

    Usually run a program with nice -n $NI_VALUE $COMMAND starts a program with a given nice value. renice -n NI_VALUE $PID changes the priority level of a process with the given pid. (multiple pid could be given to change them all)

    Sub-processes owns the same nice level with their parents.

    What about IO?

    The above works for CPU priority only. For IO control, the default priority will be cpu_priority / 5 and one can always change that using ionice.

    To make them automatic

    I recommend putting the pivotal GUI components into startup script or crontab -e(cron needed to be installed) like this:

    #"sudo crontab -e" to input
    * * * * * renice -n -4 -p $(pidof vivaldi-bin)
    * * * * * renice -n -8 -p $(pidof nautilus)
    * * * * * renice -n -8 -p $(pidof Xorg)
    * * * * * renice -n -8 -p $(pidof compiz)
    

    2017/11/19