Thursday, September 15, 2022
投資
Sunday, September 11, 2022
Beliefs
Given a subjective interpretation of reality, can we show that some beliefs cannot be identified as encodings in physical reality?
My gut feeling is that the answer is likely yes, and even if the answer is not as interesting as I thought it would be, the process of exploring it would yield interesting results.
For example, if we had a machine that, somehow purported to accurately decipher your brain neurons and tell you what you (objectively) believed, what would it be like?
Perhaps there would be instances in which the machine would claim you believed in X, but you actually believe you honestly believe in Y. Assuming the machine is really reliable due to some physical law or whatever... is this possible to have a belief that isn't encoded in physical reality, something that the machine cannot detect or will contradict you? This might be a parallel with free will vs determinism, in the objective interpretation of reality the two might not be that different, but in the subjective interpretation, beliefs seem to have more power than mere "will".
Perhaps it is useful to imagine something slightly different -- a machine that can tell you what color you perceive. It doesn't do so by just asserting the colors it displays on the screen, but rather, in addition to displaying colors on the screen, probe into your brain to try to figure out which neurons are firing. Is it possible for such a machine to misreport what you perceive?
This goes back to the question of whether we perceive the color "red" in the same way. While most people (those without a colorblind situation) can usually agree whether an object is objectively "red", there seems to be nothing physical that ensures one's perception of "red" is the same as another's. What if there is the same thing for belief?
Another funny thing about the a "belief probe" is that it might actually be able to probe the brain for "beliefs", and might actually be accurate in doing so for the overall person. But if it were only one belief, it might still not be able to accurately probe the subjective beliefs within a person. What if multiple "consciousnesses", with conflicting beliefs, were within the same physical body (as in the case of multiple personality disorders). The "tsundere" factor might also come into play, where while the probe might accurately predict behaviors, the subjective consciousness might dismiss it as superficial, because thoughts might not necessarily translate to concrete action. Is it necessary for a mere subjective feeling to always have a physical basis?
There is also the issue of meta beliefs, i.e. "belief of belief of belief ... ". Do they complicate the picture? I don't know.
It feels as if sorting this out properly could make way for identifying room that metaphysical entities might theoretically reside, if they exist.
Saturday, September 10, 2022
舊酒新瓶
本身我唔係好跟時事,舊年 NFT 熱潮推到癲瘋嗰陣,有朋友問起,我先臨急抱佛腳走去望咗兩望究竟係咩嚟。NFT 技術上大概係乜我就有少少頭緒,不過實際上點解會有人肯為咗個 token 俾成千上萬,我就一直都唔明。雖則話 crypto 嗰排水浸,有班暴發戶亂咁揈錢,但我心諗都未至於解釋得晒成個熱潮嘛?
直至最近,諗起傳統 fine art 市場。
點解一幅「名畫」可以值幾百萬?本身搵個畫師臨摹,貴極都唔使嗰個價,隨時搵個夠撩倒嘅,一千幾百有找。啲「名畫」嘅價值其實都唔係在於藝術品實物,而係作品背後嘅「故事」。咩「X畫家唯一傳世真跡」、「Y畫家臨終時最後作品」,呢啲喺外人眼中都係虛無縹緲嘅嘢,支撐咗啲「名畫」大部份嘅「價值」。大家都相信佢好值好貴,所以就值好貴。
睇返呢啲吹水嘢,同 NFT 比較,真係完全冇分別。
至於 NFT 係咪呃人,就好似我畫張圖,我話佢賣一千蚊,咁係咪呃你?
| 《勇者打怪圖》筆者畫 |
都係願者上釣㗎啫。
如果我話「遲啲市價會更貴,有人會用一萬蚊買㗎」咁就真係呃鳩你喇。
Thursday, September 8, 2022
「教主」
好似啱啱出咗 https://stevejobsarchive.com/
我 2010 年入公司,嗰陣佢已經係*唔知乜*末期,已將大部份工作交咗俾 Tim Apple。Tim 處事四平八穩,聽聞以前死鬼老細啲 all hands meeting 多啲有趣嘢聽 (同埋以前公司細啲,人少少冇咁拘謹)。冇機會見識,回想返都幾可惜。
第一次同佢有比較深刻嘅接觸,已經係公司為佢舉辦嘅紀念活動。(一時搵唔到官方嘅嘢,可能刪咗?老翻片喺度 https://www.youtube.com/watch?v=ApnZTL-AspQ )本身我對佢冇咩認知,見坊間啲人對佢評價兩極,覺得好不可思議。由於同我有比較切身關係,偶然都會留意下或自己搵下資料睇下係咩一回事。
所以就有早幾個月嘅體會。死鬼老細最出名係做蘋果同Pixar CEO,不過以打機嘅「職階」計算,佢應該歸類為「先知」。睇返佢以前嘅訪問,睇得出佢收收埋埋啲學識都好得人驚。正所謂「愛就係選擇」,佢只不過選擇咗搞 consumer electronics 咁解。
Sunday, August 21, 2022
玩 AI 製圖,玩咗個幾星期
早前喺 HN 見到關於 DALL-E 嘅 blog post,講用 AI 製圖擺囉個 blog 度。咁啱(?)我有堆冇人睇嘅文,有時想搵啲圖嚟襯托下,但又懶得自己整,就心諗不如又試下。
然後發現 DALL-E 係 closed beta,又話驚 deep fake 呢樣嗰樣,俾錢都冇得用 (要等佢皇恩浩蕩賜你access)。 不過既然有咗呢啲技術,坊間類近嘅軟件同服務其實都唔少。呢幾日嚟,搵到呢啲:
- https://www.reddit.com/user/Wiskkey/comments/p2j673/list_part_created_on_august_11_2021/
- https://github.com/nerdyrodent/VQGAN-CLIP
- https://github.com/nerdyrodent/CLIP-Guided-Diffusion/
- https://github.com/mehdidc/feed_forward_vqgan_clip
- https://github.com/openai/glide-text2im
- https://github.com/alembics/disco-diffusion
真係好靚㗎。(所以小心啲,好易一玩就沉迷落去唔見咗幾個鐘。)咁我主要就係想喺個 blog 度 gen 圖,所以啲見得人嘅製成品喺度: https://hnfong.github.io/public-crap/ —— 唔係篇篇文都有,不過呢兩年嘅文大概一半都有張配圖,應該係。
另外都試咗 VQGAN-CLIP 嗰堆,雖然啲結果同實物都好「神似」,但完全唔夠「像真」。本身以為 disco-diffusion 集各家之大成應該有啲睇頭,但我玩咗成個 weekend 完全駕馭唔到佢,可能佢「畫畫」唔錯啦,但流於「抽象派」。另外佢原本個 github 竟然係一個幾千行嘅 python file,又冇啲合理嘅 requirements.txt。望住佢啞咗,好彩搵到個 fork 幫佢執返靚啲 code 同 setup instructions⋯
Tuesday, July 12, 2022
How to really fix django sqlite3 database is locked errors
So, you run a web site with < 1 page view per second. The site is basically a CRUD app and the page is typically generated within a fraction of a second.
You decide that using sqlite as database backend is fine because you don't need to scale.
Then, users making edits complain about random server errors. You find that they are caused by
`sqlite3.OperationalError: database is locked`
Fine. Google the error. There are some stack overflow discussions, but this seems to be the authoritative diagnosis:
| https://docs.djangoproject.com/en/4.0/ref/databases/ |
So you try to set the timeout value to a large number. It doesn't work. "Database locked" errors persist. Now you're intrigued.
You run down the rabbit hole of integer overflows (apparently setting timeout value larger than 2147483.647 is a bad idea), second vs millisecond units, in-memory test databases having a different mechanism, etc. All are false leads.
So you persist. Try to reproduce the problem.
@transaction.atomic
def view1(req):
sleep(3) # <- insert some artificial delay
# do_db_writing_stuff...
@transaction.atomic
def view2(req):
# do_other_db_writing_stuff
Yay, it reproduces! (it seems)
You realize it's easily reproducible (no huge concurrency required). Just run view1 and then view2. And weirdly, if there was a timeout you'd expect view2 to get the database locked error, but surprisingly view1 gets it. Also, this 3 second sleep is lower than the database timeout anyway. This matches the observation that in production loads nothing is stuck for longer than the default database timeout, and it still fails.
So... fake error message? Maybe it's actually a deadlock?
Google "sqlite3 deadlock".
| https://stackoverflow.com/questions/55831645/how-does-sqlite-prevent-deadlocks-with-deferred-transactions |
Now we're talking!
This stackoverflow question is a true gem -- it laid out the problem clearly, and then basically answered itself. The sqlite default behavior is designed to deadlock, and when it detects one, it just throws an error ("database is locked"). It's worth quoting the original question that lays out the deadlock case:
This sounds like a multiple readers/single writer lock with arbitrary reader-to-writer promotion mechanism, which is known to be a deadlock hazard:
A starts transaction
B starts transaction
A acquires SHARED lock and reads something
B acquires SHARED lock and reads something
A acquires RESERVED lock and prepares to write something. It can't write as long as there are other SHARED locks so it blocks.
B wishes to write so tries to take RESERVED lock. There is already another RESERVED lock so it blocks until it is released, still holding the SHARED lock.
Deadlock.
Fix SQLite "database is locked" problems using "BEGIN IMMEDIATE"
| https://docs.djangoproject.com/en/4.0/ref/databases/ |