發表文章

目前顯示的是 9月, 2018的文章

Python 筆記:Package Import, Absolute & Relative

一直被 import 搞的頭暈眼花不是辦法,筆記一下: Import 分成 absolute path, relative path 兩種 absolute path 如同 Java package,使用 fully-qualified name 指定,搜尋時從 sys.path 尋找完整的套件名稱 relative path 如同檔案、URI 相對路徑,由 "." 或是 ".." 起始,搜尋相對於目前模組位置的套件 PEP-8 過去曾反對使用相對路徑,因為當時版本效能不好,目前已修正,承認相對路徑在專案開發時,有許多的好處,也是可以接受的作法 Import 的搜尋路徑 import 指令搜尋路徑,最簡單的想法是搜尋 sys.path sys.path 會包含 command line 指令中,腳本所在目錄: 例如:working_dir$ /path/to/script/filename.py,那就包含 working_dir/path/to/script 但是不會包含 working_dir sys.path 也會包含 PYTHON_PATH 這環境變數 有些 IDE,如:Eclipse,會將專案根目錄,加到 PYTHON_PATH 中,或是修改腳本啟動的工作目錄,要注意 個人短評 套件內部使用相對路徑匯入模組,很大的好處是套件可以在專案中任意搬動 但是匯入其他外部套件、模組時,如果也是使用相對路徑,自己的套件搬動就會遇到大問題 或許比較好的方式是:相同套件模組用相對路徑,其他套件模組用一個絕對路徑引用、重新命名(import ... as ...),再從該套件引用模組 可以利用 __init__.py,將套件內部實作抽象化,避免直接引用外部套件的絕對路徑 參考 https://stackoverflow.com/a/5811548/1825443 https://chrisyeh96.github.io/2017/08/08/definitive-guide-python-imports.html#summary--key-points

論文筆記:Data Distillation: Towards Omni-Supervised Learning

最近在看這篇文章,發現網路上的翻譯不太完整,缺少文章最核心的實驗方法。把自己的中文翻譯放上來獻醜,如有錯誤請讀者指教。 參考資料 原文  https://arxiv.org/pdf/1712.04440.pdf CSDN 部分翻譯  https://blog.csdn.net/sunshine_010/article/details/80038491 知乎  https://www.zhihu.com/question/264009268 --- (前略,請參考 CSDN 的翻譯) Generating labels on unlabeled data. By aggregating the results of multi-transform inference, it is often possible to obtain a single prediction that is superior to any of the model’s predictions under a single transform (e.g., see Figure 2). Our observation is that the aggregated prediction generates new knowledge and in principle the model can use this information to learn from itself by generating labels. 標註未標註的資料 組合多種幾何轉換的推論結果,通常能得到比單一幾何轉換更好的結果。 根據我們觀察,組合的結果能產生新的知識。一般而言,既有模型能夠透過產生新標記,來自我訓練。 Given an unlabeled image and a set of predictions from multi-transform inference, there are multiple ways one could automatically generate labels on the image. For example, in the case of a classificatio