[Python] yield 與生成器
介紹
yield
是 Python 中的一個關鍵字,它的使用場景與 return
很像,不過使用 yield
會把函式變成一個生成器(generator)。
yield
是 Python 中的一個關鍵字,它的使用場景與 return
很像,不過使用 yield
會把函式變成一個生成器(generator)。
FastAPI 是一個現代、高效的 Python web 框架。基於 python 3.7+ 並且擁有 python type hints。
Read More »[Python] 使用 FastAPI 框架進行後端開發筆記前陣子閱讀了不少 LLaMA 的各種 LoRA 模型訓練(雖然已經大概是兩個月前…),在閱讀各家程式碼的時候,發現在程式碼中設定給予模型的 prompt 時,若需要根據不同的資料調整內容,使用 format_map()
的格式看起來最為乾淨。
Given a directed acyclic graph, with n
vertices numbered from 0
to n-1
, and an array edges
where edges[i] = [fromi, toi]
represents a directed edge from node fromi
to node toi
.
Faiss 是 Facebook AI Research 團隊所開發的一款高效向量匹配函式庫,只要輸入向量後,就能夠在大量的高維度向量中迅速匹配最相像的 top k 個向量。
Read More »[Python] 使用 Faiss 相似度搜索快速匹配向量Given two 0-indexed integer arrays nums1
and nums2
, return a list answer
of size 2
where:
answer[0]
is a list of all distinct integers in nums1
which are not present in nums2
.answer[1]
is a list of all distinct integers in nums2
which are not present in nums1
.There is a function signFunc(x)
that returns:
You have a set which contains all positive integers [1, 2, 3, 4, 5, ...]
.
Implement the SmallestInfiniteSet
class: