搜尋此網誌

2026年7月8日星期三

Exercise of Python Learning

「除數」(divisor)是在除法算式中,用來「除」另一個數字(被除數)的數字。以 12 ÷ 4 = 3 為例,被除數是 12,除數是 4,商是 3。若指整數的整除關係,除數在中文也常被稱為「因數」(factor)。

def allPrimesUpTo(num):

    primes = [2]

    for number in range(3, num):

        sqrtNum = number**0.5

        for factor in primes:

            if number % factor == 0:

                break

            if factor > sqrtNum:

                primes.append(number)

                break

    return primes

print(allPrimesUpTo(20))


Function definition
Creates a function that will return all prime numbers less than num.

Initialize list of primes
Starts with [2] because 2 is the first prime number.
This list will grow as new primes are found.

Loop through candidate numbers
Tests every integer from 3 up to num - 1.

Compute square root
Finds the square root of the candidate number.

Check divisibility against known primes
for factor in primes:
Loops through all primes found so far.
This is efficient: instead of checking every integer, you only check prime factors.

Case 1: divisible by a prime
if number % factor == 0:
    break
If number is divisible by any prime factor, it’s not prime.
break exits the loop immediately.

Case 2: factor exceeds square root
if factor > sqrtNum:
    primes.append(number)
    break
If you’ve checked all prime factors up to the square root and none divided evenly, then number must be prime.
Append it to the list of primes.
break stops checking further factors (no need).

Example trace (num = 20)

  • Start: primes = [2]

  • number = 3 → factors checked: 2 (not divisible, 2 > √3) → add 3 → [2, 3]

  • number = 4 → divisible by 2 → skip

  • number = 5 → factors: 2 (not divisible), 3 (3 > √5) → add 5 → [2, 3, 5]

  • number = 6 → divisible by 2 → skip

  • number = 7 → factors: 2 (not divisible), 3 (3 > √7) → add 7 → [2, 3, 5, 7]

  • number = 8 → divisible by 2 → skip

  • number = 9 → divisible by 3 → skip

  • number = 11 → factors: 2 (not divisible), 3 (not divisible), 5 (5 > √11) → add 11 → [2, 3, 5, 7, 11]

  • … continues until 19.

Microsoft Copilot

A Public Letter

Currier House is one of twelve undergraduate residential Houses of Harvard College.

NCR: National Cash Register

staggering: so great, shocking or surprising that it is difficult to believe

exclusive: only to be used by one particular person or group; only given to one particular person or group

self-referential: referring to the fact of actually being a work of literature, or to the author, or to other works that the author has written

devote: to give all of something, especially your time, effort, or love, or yourself, to something you believe in or to a person

chastise: to criticize somebody for doing something wrong

pony up: to pay money for something

royalty: a sum of money that is paid to somebody who has written a book, piece of music, etc. each time that it is sold or performed

overhead: regular costs that you have when you are running a business or an organization, such as rent, electricity, wages, etc.

break-even: to complete a piece of business, etc. without either losing money or making a profit

please: to make somebody happy

deluge: to send or give somebody/something a large number of things at the same time

grist: grist (for somebody/something) useful ideas or material

hunk: a large piece of something, especially food, that has been cut or broken from a larger piece

slam: to criticize somebody/something very strongly

irate: very angry

outrage: to make somebody very shocked and angry

diplomatic: having or showing skill in dealing with people in difficult situations

Business stationery encompasses the customized printed materials a company uses for day-to-day communication and brand representation. It includes any document or branded piece sent to clients, vendors, or the public, such as business cards, letterheads, envelopes, and presentation folders.

screed: a long piece of writing, especially one that is not very interesting

onstage: on the stage in a theatre; in front of an audience

convention:  the way in which something is done that most people in a society expect and consider to be polite or the right way to do it

confab: an informal private discussion or conversation

stunned: ​very surprised or shocked; showing this

envision something (formal) to imagine what a situation will be like in the future, especially a situation you intend to work towards

A "scrum of people" refers to a dense, chaotic crowd where individuals push and jostle against each other to get somewhere or grab something.

A mental metronome can refer to an internal cognitive skill or a specialized therapeutic tool.

hinge on: ​(of an action, a result, etc.) to depend on something completely

enigma: a person, thing or situation that is mysterious and difficult to understand

couch: ​a long comfortable seat for two or more people to sit on

PO box: a box with a number in a post office to which your letters and parcels can be sent and from which you can collect them

scribble: to write something quickly and carelessly, especially because you do not have much time

concerted: done together by more than one person, government, country, etc.

Bill Gates "Source Code"

hk.dictionary.search.yahoo.com

oxfordlearnersdictionaries.com

dictionary.cambridge.org

Google AI overview

2026年7月7日星期二

本機算力 vs 雲端算力

把 AI 功能放在手機「先用本機算力」通常既有技術理由也有商業策略成分;廠商會根據產品定位、成本、隱私法規與使用者體驗來決定本地運算與雲端運算的比例。

廠商會優先用本機算力的原因︰

  • 延遲與即時性:本地推理延遲低,適合即時互動(語音助理、相機即時增強)。

  • 隱私與合規:敏感資料可留在裝置上,降低跨境或雲端傳輸的合規風險。

  • 成本控制:長期看可減少雲端推理費用與頻寬成本。

  • 離線可用性:無網路時仍能提供基本功能。

  • 差異化賣點:以「更快、更私密、低流量」作為市場訴求。

Microsoft Copilot

漢語和人工智能

漢字結構包括象形、指事、會意、形聲,以漢語訓練出來的人工智能與西方國家創造出來的有明顯的分別嗎?

用漢語語料訓練的模型在語言表徵、文化偏向與本地化表現上通常有明顯優勢,但在核心架構與基礎能力(如推理、算力需求)上與西方模型並非本質不同,更多是「優化方向與應用生態」的差異。

語言結構影響 token 與效率:漢字每字語義密度高,對 tokenizer 與上下文窗口利用率有不同影響,可能降低推理成本或改變訓練策略。

文化與價值觀嵌入:模型會反映訓練語料的文化傾向;中文原生模型在本地文化、語域與禮貌用語上更貼近華語使用者。

技術相似但生態不同:基礎架構(Transformer、訓練技巧)全球通用,但資料來源、監管、部署速度與商業模式在中西有顯著差別。


Token 是自然語言處理中把文字切分成的最小單位,模型以 token 為基本運算單位來學習與生成語言。token 可以是字元、子詞、整詞或字節序列,取決於所用的 tokenizer。

常見 tokenizer 類型

字元型:每個字或字母為一個 token。

子詞型(例如 BPE、WordPiece):把常見字串當作 token,能平衡詞彙覆蓋與詞表大小。

字節級(Byte-level):對任意語言都穩定,處理未知字詞更健壯。

Modified from Microsoft Copilot

星芒拍攝

一般來說,定焦鏡因光學結構簡單、葉片形狀更規則,星芒線條往往更銳利;變焦鏡則因葉片數量與形狀差異,星芒可能較柔和或不均勻。

星芒是由光圈葉片邊緣的衍射造成,葉片數量決定星芒線條數。光圈葉片數量為偶數時,星芒條數等於光圈葉片的數量;光圈數目為單數時,星芒條數則為光圈葉片數目的兩倍。例如︰

  • 6片葉 → 6條星芒
  • 7片葉 → 14條星芒
  • 9片葉 → 18條星芒
Microsoft Copilot
上田晃司《全圖解 馬上提昇功力的57個攝影妙方:一目了然的專業級表現手法!》

Physiological sigh

limbic system: a system of nerves in the brain involving several different areas, connected with basic emotions such as fear and anger and basic needs such as the need to eat and to have sex

swiftly: quickly; after a very short time

pivotal: of great importance because other things depend on it

uncouple: to remove the connection between two vehicles, two parts of a train, etc.

loom: (of something bad) to appear serious and likely to happen soon

linger: to continue to exist for longer than expected

mundane: not interesting or exciting

household: all the people living together in a house or flat

"Laugh his socks off" is an informal English idiom meaning to laugh uncontrollably or heartily.

Ts&Cs: abbreviation for terms and conditions

testament: a thing that shows that something else exists or is true

bewilderment: a feeling of being completely confused

over-the-top: done with too much acting, emotion or effort

primitive: belonging to an early stage in the development of humans or animals

huff and puff: ​to breathe loudly, usually after physical exercise

Border collie: ​a medium-sized black and white dog, often used as a sheepdog

connotation: an idea suggested by a word in addition to its main meaning

hardwired: ​(of a skill, quality or type of behavior) present as part of who you are and the way your brain is made, not learned from experience

fast-track: to make somebody’s progress in achieving something, for example a high position in a job, quicker than usual

deliberately: done in a way that was planned, not by chance

When we're stressed, our breathing becomes shallow and some of the alveoli in our lungs can collapse, which increases the carbon dioxide levels in our blood. The abundance of carbon dioxide causes us to feel stressed and agitated, which is why taking deep breaths can feel calming.

The physiological sigh is a rapid breathing technique proven to reduce acute stress and anxiety. It involves a double inhale (a deep breath followed by a short top-up breath) through the nose, followed by a slow, extended exhale through the mouth.

This intentional breathwork triggers the parasympathetic nervous system to immediately lower your heart rate and calm your nervous system.

Neuroscientist Dr. Andrew Huberman stated that the physiological sigh could serve as an anxiety-reducing tool by giving the individual autonomy and control.

壓力時呼吸變淺,部分肺泡可能萎陷,血液中二氧化碳濃度上升。二氧化碳過多會讓人感到緊張與躁動,因此深呼吸會有鎮定效果。生理嘆息是一種經證實能減輕急性壓力與焦慮的快速呼吸法:先用鼻子做一次深吸,再補一次短吸,然後用口慢慢長呼氣。這種刻意的呼吸會啟動副交感神經,立即降低心率、平復神經系統。神經科學家 Dr. Andrew Huberman 指出,生理嘆息還能讓人恢復自主感與控制感,從而減少焦慮。

Modified from Microsoft Copilot

hallmark: a feature or quality that is typical of somebody/something

Nicole Vignola "Rewire"

hk.dictionary.search.yahoo.com

oxfordlearnersdictionaries.com

dictionary.cambridge.org

Google AI overview

裁切之外

Compare full frame 216 mm and canon aps-c 135mm

視角:兩者的等效焦距都是 216mm,所以在取景範圍上是一樣的。

光學特性:

Full Frame 216mm → 真實的 216mm 光學焦距。

APS‑C 135mm → 光學上是 135mm,但因感光元件裁切,視角等效 216mm。

景深:

Full Frame 216mm → 景深較淺,壓縮感更強。

APS‑C 135mm → 雖然視角相同,但景深特性仍是 135mm 的,背景虛化程度比 FF 216mm 稍弱。

Microsoft Copilot