The following code is only tested on Apple Silicon.

  1. Config Git

    1
    2
    3
    4
    5
    git config user.name <your_name>
    git config user.email <your@email.address>
    git config -l # list git config
    ssh-keygen -t rsa -C "your@email.address"
    cat ~/.ssh/id_rsa.pub

    Copy rsa public key to GitHub->Settings->SSH and GPG keys.

  2. Install Nodejs

    1. In China, you may consider install cnpm

      1
      sudo npm install -g cnpm --registry=https://registry.npm.taobao.org
    2. In the following steps, I will use cnpm, same for npm.

Read more »

Here is some tips for tensorflow1.x.

  1. print tensor

    1
    2
    3
    self.p = tf.Print(<input tensor>, ['<message>', <printed tensor>], summarize=100)

    sess.run(model.p)
  2. print model weight. find the corresponding op name in tensorboard

Read more »

Here is some tips for pytorch1.x.

tensor

1
2
3
4
5
6
7
8
9
10
11
12
13
14
>>> import torch
>>> torch.tensor([1]).dtype
torch.int64
>>> torch.tensor([1], dtype=torch.float32).dtype
torch.float32
>>> torch.tensor([1.]).dtype
torch.float32
>>> torch.Tensor([1]).dtype
torch.float32
>>> torch.tensor([True]).dtype
torch.bool
>>> torch.Tensor([True]).dtype
torch.float32
>>> exit()

note: torch.tensor will auto guess the type; torch.Tensor is same with dtype=float32

Read more »

  1. Use lshw (list hardware) to show the computer hardware information.

  2. Use uanme -a to show system information.

  3. tar

    1
    2
    3
    4
    5
    6
    tar –xvf file.tar # unzip .tar
    tar -xzvf file.tar.gz # unzip .gz
    tar -xjvf file.tar.bz2 # unzip .bz2
    tar –xZvf file.tar.Z # unzip .Z
    unrar e file.rar # unzip .rar
    unzip file.zip # unzip .zip
  4. Show the structure of current directory.

    1. sudo apt install tree
    2. tree -L N show \(N^{th}\) depth.
Read more »

  1. check local modification

    1. git stash temporally store modification in stash.
    2. git stash pop restore modification from stash.
    3. git checkout . cancel all local modification.
    4. git reset --hard HASH reset to certain HASH commit, losing all local modification.
  2. ssh -T git@github.com test your ssh connection with github.

Read more »

  1. install

  2. test installation: docker container run hello-world

  3. switch docker image repository

    1. sudo mkdir -p /etc/docker

    2. vim /etc/docker/daemon.json Replace the mirror with your own.

      1.    {
             "registry-mirrors": ["https://yxzrazem.mirror.aliyuncs.com"]
           }
    3. sudo systemctl daemon-reload; sudo systemctl restart docker

  4. add user to docker group (you can run docker commands without sudo)

    1. sudo groupadd docker
    2. sudo usermod -aG docker $USER
    3. newgrp docker
    4. verify: docker run hello-world
  5. restart docker service sudo service docker restart

  6. list docker images: docker images or docker image ls

  7. list containers: docker ps; list all containers: docker ps -a

  8. remove containers: docker rm <container id 1> <container id 2> ...; remove all stopped containers: docker rm $(docker ps -a -q status=exited) or docker container prune

  9. run container: docker run <container id>/<image id> <command>; run container with interface: docker run -it <container id>/<image id> bash

cpplint

cpplint is a static code checker for C++, following Google C++ styles.

– check code format

1
2
pip install cpplint
cpplint.py --verbose=3 test.cpp # only consider warning level > 3

C++ code style

  1. install miniconda in M1
  2. create and enter new environment of conda
  3. conda install -c conda-forge opencv
    1. opencv will be available in this environment.
  4. test opencv: python -c "import cv2; print(cv2.__version__)"
0%