-
PyTorch summary
About the dimension In most cases, system throws a warning because you made a wrong data dimension operation. Watch out the dimension of specific data, you can use the following code to test. w1 = torch.tensor([[1, 2, 1]]) # torch.Size([1, 3]) w3 = torch.tensor([1, 2, 1]) # torch.Size([3]) w2 = w1.view(-1) # in fact, w2 = w3 So there is ... Read More
-
Update Python and Conda
word = "Hello" print('word =', word) print(f'word = {word}') print(f'{word = }') conda update conda conda update anaconda setting of jupyter notebook package pip install jupyterthemes or conda install -c conda-forge jupyterthemes conda update jupyterthemes jt -t chesterish -f iosevka -fs 140 -altp -tfs 13 -nfs 115 -lineh 165 -cu... Read More
-
CMD commonly used command
Shutdown, restart Shutdown after 3600s shutdown /s /t 3600 shutdown /s shutdown /r Directory operation enter d d: return root directory cd \ return the last directory cd .. enter test2, Case insensitive, tab completion cd test1\test2 cd /d d:/test Show content dir cd tree d:\test cd d: Internet 延迟和丢包率:p... Read More
-
Matrix Derivative
Different notations Notice that if we think $f$ expands in a column way, i.e., $\frac{\partial f}{\partial x}=\left[\begin{array}{cccc}\frac{\partial f_1}{\partial x_1} & \frac{\partial f_2}{\partial x_1} & \cdots & \frac{\partial f_m}{\partial x_1} \ \frac{\partial f_1}{\partial x_2} & \frac{\partial f_2}{\partial x_2} & \c... Read More
-
Machine learning to solve large TSP
Reference 1 2 3 4 5 https://sagemaker-examples.readthedocs.io/en/latest/reinforcement_learning/rl_traveling_salesman_vehicle_routing_coach/rl_traveling_salesman_vehicle_routing_coach.html 7 8 9 Read More
-
How to test Python in Leetcode
实例化类(Manually) After finishing your method, copy the input in the example, then have a test. class Solution: def gcdOfStrings(self, str1: str, str2: str) -> str: return '' if __name__ == "__main__": s = Solution() # 测试Example中的用例1 # Input: str1 = "ABCABC", str2 = "ABC" # Output: "ABC" str1 = "ABCABC" str2 = "ABC" ... Read More
-
Skills frequently used in Python
add on that Usage of Bisect bisect是python内置模块,用于有序序列的插入和查找。 查找: bisect(array, item) 插入: insort(array,item) import bisect a = [1,2,2,5,8] position = bisect.bisect(a,7)#找到插入位置 print(position) # 4 bisect.insort(a,4)#找到位置插入 print(a) # [1, 2, 2, 4, 5, 8] bisect.bisect_left(a,2)#插到左侧 # 1 bisect.bisect_right(a,2)#插到右侧 # 3 Usage of Counter Retu... Read More
-
Useful Idioms II
‘The best of both worlds’ – means you can enjoy two different opportunities at the same time. “By working part-time and looking after her kids two days a week she managed to get the best of both worlds.” ‘Speak of the devil’ – this means that the person you’re just talking about actually appears at that moment. “Hi Tom, speak o... Read More
-
Some phases Ⅰ
Have some faith: 有点信心 just in case: 以防万一 this is legit: 这非常棒 Leave it alone:别管了 I told you so: 我早就告诉过你 That depends:要看情况而定 Never mind: 算了 Forget about it: 算了吧,别想它了 It’s a long story: 说来话长了 Believe it or not: 信不信由你 I coundn’t help it:我忍不住了(想做某件事情) don’t get me wrong:别误解我 don’t bother:别费心了 don’t waste your energy:别费劲了 stop wasting y... Read More
-
Basic elements convert in Python
List to Dictionary a = ['a1','a2','a3','a4'] b = ['b1','b2','b3'] d = zip(a,b) print(dict(d)) # {'a1': 'b1', 'a2': 'b2', 'a3': 'b3'} Use counter to obtain a aggregated form from List from collections import Counter counter_dic = Counter(counter_list) Dictionary to List list(dit) # key list(dit.values()) # value List to Numpy array i... Read More