Shooting's Blog

0412 Rosa time

4/12 Level2
The most important thing for the government to improve health care is to clean the environment.
Do you agree or disagree? Please provides specific reasons and details to support your answer.

[32mins] 458 words

People usually possess different perspective on whether the most important thing for the government to improve health care is to clean the environment. Based on my observation and life experience, I disagrees that the most important thing for the government to improve health care is to clean the environment.

First of all, in order to improve health care, it is important to have more medical facilities, but cleaning the environment cannot help government with this purpose. For example, one of my friend, David, broke his leg in a car accident in Green Island, where there is only one hospital in the whole island, near Taiwan. In addition, the facilities in the hospital are too old to be able to make delicate surgeries. Under this circumstances, David can only took a plane flying back to Taiwan to get treatments. As a result, he lost his leg because he waited too long to handle the injuries. Accordingly, it is important for the government to expand and renew the medical facilities to take care of patients.

Secondly, to improve health care, decreasing working hours of doctors is necessary, but to clean the environment cannot achieve this goal. For instance, there was a lawsuit related to a medical issue. A patient got huge bleeding after he left the hospital few days later. Therefore, she was sent to emergency room and had second surgery. And it turned out that a surgery knife was left in patient's stomach because the doctor who did the surgery had worked for more than 15 hours in a row. He was not able to keep concentrating and taking care of everything. Therefore, it is important for government to force hospital reducing the working hour of doctors in case these kinds of medical mistakes happen again.

Last but not least, funding poor people to be able to see a doctor is also important for improving health care, and cleaning the environment cannot allow government to do so. For instance, my cousin John had headache problem since two years ago. He only earns 15,000 NTD per month while seeing a doctor may cost at least 3,000 NTD. So, he did not go to a doctor until he fall unconscious this month. Then, he did the examined after sending to emergency room, finding he had a brain cancer which was unable to cure. Apparently, if government can sponsor part of medical expense for poor people, he will have more chances to be cured since he can see doctors as early as possible.

In conclusion, I strongly disagree that the most important thing for the government to improve health care is to clean the environment. Instead, having more medical facilities, decreasing working hours of doctors, and funding poor people are more important.


[20 mins] 278 words

Both the reading and the lecture discuss the population of the yellow cedar. The reading proposes three advanced hypotheses to explain the decline of the population of the yellow cedar. However, the professor strongly disagrees with the reading. Accordingly, he proposes three refutations.

First of all, the reading indicates that the yellow cedar decline may be caused by insect parasites, specially the cedar bark beetle. Yet, the lecturer challenges the statement by arguing that the healthy yellow cedars are resistant to other species. Furthermore, the cedar bark beetle attacks those sick yellow cedars which will die anyway. As a result, attack of cedar bark beetle is not the main cause.

Secondly, the passage mentions that the decline is attributed to brown bears. Nevertheless, the speaker refutes the hypothesis by maintaining that bear damage will not lead to decline of the bears. The population of yellow cedar have also been declining in mainland or island where there are no bears. To be more specific, the decline exists with or without those brown bears. Therefore, the decline of yellow cedar is not attributed to the brown bears.

Last but not least, the reading passage suggests that the gradual changes of climate may be to blame for the decline. Still, the scholar opposes the argument because the scientists did not take one factor into account. To elaborate, more yellow cedar die in lower elevation where the weather is warm than in higher elevation where the weather is cold. This directly contradicts the expectation that the yellow cedar should die more at low elevation. Apparently, although climate change makes the yellow change become sensitive, it is not the main reason which kills them.

In conclusion, the speaker strongly contradicts the reading passage. In other words, the decline of yellow cedar cannot blame to the three hypotheses mentioned in the reading passage.


Coursera course



  • Various way to adjust the model.

    • Increase dense layer -> Training takes longer, but is more accurate.
    • Remove Flatten() layer -> Get an error about the shape of the data.
    • Revise the final output layer to be differed from classified category -> Get an error as soon as it finds an unexpected value.
    • Add additional layers in the network -> No big impact due to simple data.
    • More poches -> overfitting
    • Don't normalize data
    • Stop the training when reached a desired value
  • Stop the training when it reaches a certain condition, such as accuracy>0.5 or loss<0.5

    • Implement a callback to stop training.
    • Check the condition at the end of epoch.
    • Because while data is not completed processed, the acc or loss may be up and down.
    • Trigger the callback.
  • Exercise sheet


Artificial Intelligence (AI)

Recommend learning material

Recommend book

AI / Machine learning / Deep learning

  • Definition
    • AI > Machine Leraning > Deep Learning
    • AI: intelligent machines that work and react like humans. AI systems use detailed algorithms to perform computing tasks much faster and more efficiently than human minds.
    • Machine learning: the ability of machines to automate a learning process.
    • Deep learning: a subsection of machine learning (and thus artificial intelligence) that focuses on a family of models called artificial neural networks (ANN). The “deep” part of deep learning is a technical term and refers to the number of layers or segments in the “network” part of “neural networks.”

Maing Tool

  • Keras
    • An open-source neural-network library written in Python. It is capable of running on top of TensorFlow, Microsoft Cognitive Toolkit, Theano, or PlaidML. It is designed to enable fast experimentation with deep neural networks.
    • In 2017, Google's TensorFlow team decided to support Keras in TensorFlow's core library.
    • Keras was conceived to be an interface rather than a standalone machine-learning framework.
  • TensorFlow

    • TensorFlow is a free and open-source software library for dataflow and differentiable programming across a range of tasks. It is a symbolic math library, and is also used for machine learning applications such as neural networks.
  • PyTorch

    • An open-source machine learning library for Python, based on Torch, used for applications such as natural language processing.

Convinent tool

  • Google Colab

C++11 pointer

Pointer types


    • 確保一份資源(被配置出來的記憶體空間)只會被一個 unique_ptr 物件管理的 smart pointer;當 unique_ptr 物件消失時,就會自動釋放資源。

    • 可以有多個 shared_ptr 共用一份資源的 smart pointer,內部會記錄這份資源被使用的次數(reference counter),只要還有 shared_ptr 物件的存在、資源就不會釋放;只有當所有使用這份資源的 shared_ptr 物件都消失的時候,資源才會被自動釋放。

    • 搭配 shared_ptr 使用的 smart pointer,和 shared_ptr 的不同點在於 weak_ptr 不會影響資源被使用的次數,也就是說的 weak_ptr 存在與否不代表資源會不會被釋放掉。
    • 由於 weak_ptr 本身不能用來做資料的存取,所以如果要使用的話,實際上是需要先將 weak_ptr 轉換回 shared_ptr 的。轉換的方法也很簡單,就是使用 weak_ptr 提供的 lock() 這個函式,來產生一個有擁有權的 shared_ptr。

Difference in make_shared and normal shared_ptr in C++

  • The difference is that std::make_shared performs one heap-allocation, whereas calling the std::shared_ptr constructor performs two.

  • std::shared_ptr manages two entities:

    • the control block (stores meta data such as ref-counts, type-erased deleter, etc)
    • the object being managed
  • std::make_shared performs a single heap-allocation accounting for the space necessary for both the control block and the data.

Java's pointer concept

  • 只要還有strong reference指著,就不會被gc
  • 被weak reference指著的object,還是有可能被gc,就是有權去回收weak reference指向的object,使用weak reference的user要能handle。


Avoid memory leak

C++11 smart pointer series

Difference in make_shared and normal shared_ptr in C++

How to create shared_ptr

Repo Problem

Repo sync failed


  • Repo Sync failed (error: branch xxx is published (but not merged) and is now n commit behind)
  • Cannot do ‘mtk_repo sync’ (after last upload to Gerrit) is published (but not merged) and is now x commits behind since last upstream (R1)


  C1 <- C2 <- C3 <- N1 <- N2 <- N3 <- N4 <- N5 (Server latest)
              (branch1)  (cherry-pick)
  • R1 != N3 (even R1 is picked/rebased)
  • Local is R1, server latest is N5


1.1: repo start $localbranch . to create a new local branch
1.2: repo sync . to update local branch to latest

2.1: git remote update to fetch objects from remotes
2.2: git reset --hard <remote>/<branch> to reset local branch as the same as server
------ (git remote to get remote names)


What is simpleperf ?

  • 在 Linux 上內建提供 perf tool, 可以用它做效能的分析.
  • 而 Android 上, Google 利用同樣概念, 提供 simpleperf 工具

How simpleperf works ?

Simpleperf 利用 CPU 內的 PMU,將需要的事件不斷的輸出 (比方 cpu-cycles ),
以達到監控每個CPU每個瞬間跑在哪一行 arm 指令.
透過這樣取樣的方式, 我們可以假設取樣到同區域的次數越多, 代表該段代碼越可能是執行瓶頸.


adb root
adb remount
adb push simpleperf /data
adb shell chmod 755 /data/simpleperf
adb shell "/data/simpleperf record  -g -p `pidof camerahalserver` --duration 120 -f 100 -o /sdcard/"
adb shell /data/simpleperf --log error report -i /sdcard/ > 1-self.txt
adb shell /data/simpleperf --log error report --children -i /sdcard/ > 2-children.txt
adb shell /data/simpleperf --log error report -g -i /sdcard/ > 3-caller.txt
adb shell /data/simpleperf --log error report -g callee -i /sdcard/ > 4-callee.txt

adb problem


  • Cannot use adb
C:\Users\mtk04284>adb devices
List of devices attached
* daemon not running. starting it now on port 5037 *
error: could not install *smartsocket* listener: cannot bind to
could not read ok from ADB Server
* failed to start daemon *
error: cannot connect to daemon


  • Kill process who occupy adb's port
Check who occupy 5037 port
C:\Users\mtk04284>netstat -aon | findstr "5037"
  TCP      ESTABLISHED     1584
Check which process (PID) is 1584
C:\Users\mtk04284>tasklist | findstr "1584"
spoolsv.exe                   1584 Services                   0     16,340 K
Force close Process
taskkill /pid 1584 /f   (Never tried, not sure if it works.)
Restart server
adb start-server


Adb shell

List all command supported by dumpsys

dumpsys | grep "DUMP OF SERVICE" 
Part of result
shell@m:/ $ dumpsys | grep "DUMP OF SERVICE" 
dumpsys | grep "DUMP OF SERVICE" 

Check help for dumpsys

dumpsys meminfo -h

Dump meminfo

increase dump time to 30 seconds
adb shell dumpsys -t 30 meminfo
check certain process
adb shell dumpsys meminfo camerahalserver