kwargs - Key words arguments in python function

This is a tutorial of how to use *args and **kwargs For defining the default value of arguments that is not assigned in key words when calling the function: def func(**keywargs): if 'my_word' not in keywargs: word = 'default_msg' print(word) else: word = keywargs['my_word'] print(word) call this by: func() func(my_word='love') you’ll get: default_msg love read more about *args and **kwargs in python: https://www.digitalocean.com/community/tutorials/how-to-use-args-and-kwargs-in-python-3 Add more about default value if arg key is not assigned: def make_hastie_10_2(n_samples=12000, random_state=None): """Generates data for binary classification used in Hastie et al.

READ MORE

Graph Neural Networks for Computer Vision

Graph Neural Networks for Computer Vision I was attracted by this image: This is an inspiring image and it was posted in this article: Tutorial on Graph Neural Networks for Computer Vision and Beyond (Part 1) written by Boris, a PhD student at University of Guelph. Link: https://medium.com/@BorisAKnyazev/tutorial-on-graph-neural-networks-for-computer-vision-and-beyond-part-1-3d9fada3b80d The figure I attached above is showing some possibilities that using the graph structure to represent the version components in a fuzzy way. That’s innovative and interesting.

READ MORE

Convert Adjacency matrix into edgelist

Table of Contents [Edge List <– Adjacency Matrix](# Edge List <– Adjacency Matrix) [Edge List –> Adjacency Matrix](# Edge List –> Adjacency Matrix) [About Adjacency List](#About Adjacency List) Edge List <– Adjacency Matrix ''' ref: https://www.cnblogs.com/sonictl/p/10688533.html convert adjMatrix into edgelist: 'data/unweighted_edgelist.number' or 'data/weighted_edgelist.number'' input: adjacency matrix with delimiter=', ' it can process: - Unweighted directed graph - Weighted directed graph output: edgelist (unweighted and weighted) ''' import numpy as np import networkx as nx # -------DIRECTED Graph, Unweighted----------- # Unweighted directed graph: a = np.

READ MORE

Mac 日常使用tips

29190923: 【Mac快捷键】光标及 delete 删除光标右侧文字 Ctrl + a = home Ctrl + e = end Ctrl + p = 上 Ctrl + n = 下 Ctrl + b = 左 Ctrl + f = 右 Ctrl + d = delete 删除光标右侧文字 20180725: windows标准的键盘连接了mac如何映射键盘?最大的好处是可以向后删除,还可以一键PageUP, PageDown ref: https://support.apple.com/zh-cn/HT202676 Win-> Command Alt -> Alt Ctrl-> control Mission Control: Ctrl+↑, Ctrl+←, Ctrl+→ LaunchPad: Win+F10, Or: Fn + Win + F10 in case the FnLk is not activated. Home and End disabled sometimes.

READ MORE

否定中医者多犯这个根本错误

否定中医者多犯这个根本错误 拿西方现代科学体系来评价所有的事物,包括中医。这是对西方现代科学体系的迷信。 无论是中医还是西医,都是为了解决人类健康问题。就像2个娃娃在妈妈面前,不是说娃娃A说娃娃B的做派不符合娃娃A,那你娃娃B就完全错了。而是在问题妈妈面前,谁能解决问题,谁即是可取。 无论是中医还是西医,都有其长短。拿亲身的经历举个中医行,西医不行的例子:本人由一次感冒引发肺炎,经西医抗生素治疗,病征消失大半,但咳嗽一直不得好转。西医对此解释是“炎症引起气道高反应”,从而刺激咳嗽回路因此咳嗽。这并没有错,但是如何施治?西医的检验和治疗方法都用遍了,持续4-5个月的咳嗽一直不得好转。以上都是三甲医院呼吸科专科医生提供的诊疗建议。 那么中医怎么看待这个问题?中医根据痰液的颜色等指征诊断为脾湿所致肺经紊乱,建议以六君子汤治疗十天。吃药致第五、六天时依然不见好转,心生疑虑,至第九天,见效。至第十天,病情得以完全控制,咳嗽不见。 从本例来讲,娃娃A、B都在问题妈妈面前给出了自己的解决方案,娃娃A对于主要炎症的起因解释和治疗是快捷准确的,但对于最终关键的咳嗽问题,娃娃B的方案得到问题妈妈的肯定,而不是娃娃A。 当然,对于切身经历的此次咳嗽,我本人还有很多自己的观察和思考。其中最关键的一点,我发现,消化系统的健康状况确实对呼吸系统的健康状况有很大影响。这在目前的西医呼吸科相关研究中,并未见提到。 回到主题,少抨击中医,尽管中医曾出现很多谬误,西医曾经的谬误也很多。只是,摒弃狭隘的是非对错观,拥抱“实践检验真理”的朴素科学观。认识世界要讲事实,论述世界要讲逻辑,简单的拿“娃娃B不符合娃娃A”去说“娃娃B”是完全错误的,这是一种幼稚的方法和手段,经不起推敲。中医大师施今墨所倡导的“中西医结合”,的确是值得采取的科学态度。 另外要警惕的是,由于中医是中华文化中很重要的一部分,西方敌对势力可利用抨击中医,以达到不可告人的目的。例如借此瓦解中华文化、降低中国人的民族认同感等。

READ MORE

Setting proxy for Windows CMD and Linux Terminal

I found my blog is deleted by platform! WTF? I shall transfer all my blogs to a SECURE place! As soon as possible!! Jun 07, 2021 setting proxy for Windows CMD and Linux Terminal First ref(log in as owner): https://www.cnblogs.com/sonictl/diary/2021/06/07/14859534.html Linux Terminal: set http_proxy=http://127.0.0.1:8118 set https_proxy=http://127.0.0.1:8118 set http_proxy= set https_proxy= more ref: Setting proxy for apt from terminal Windows CMD: format: set HTTP_PROXY=http://user:password@proxy.domain.com:port examples: set HTTP_PROXY=http://127.0.0.1:8118 set HTTPS_PROXY=http://127.0.0.1:8118 Use Privoxy to transfer SOCKS to HTTP/HTTPS. or Use Proxifier to manage the proxy

READ MORE

Raspbian 在虚拟机上运行,运行Flask,供宿主机访问

Raspbian 在虚拟机上运行,启动Flask,供宿主机访问 参考ref 1, 在virtualbox上跑起来Raspbian OS 参考ref 2, 在Raspbian上安装并运行Falsk, 注意要外网访问得有个参数 –host=0.0.0.0 参考ref 3, 用端口映射方法将内网ip暴露给宿主机。 映射主机 192.168.56.5556 到 宿主机 0.0.0.0:5000 在主机浏览器访问:192.168.56.5556 即可看到下图: **reference: ** http://www.penguintutor.com/raspberrypi/rpi-desktop-virtualbox https://flask.palletsprojects.com/en/1.0.x/quickstart/ https://www.cnblogs.com/Reyzal/p/7743747.html

READ MORE

gensim Load embeddings

gensim package from gensim.models.keyedvectors import KeyedVectors twitter_embedding_path = 'twitter_embedding.emb' twitter_vocab_path = 'twitter_model.vocab' foursquare_embedding_path = 'foursquare_embedding.emb' foursquare_vocab_path = 'foursquare_model.vocab' # load the embedding vector using gensim x_vectors = KeyedVectors.load_word2vec_format(foursquare_embedding_path, binary=False, fvocab=foursquare_vocab_path) y_vectors = KeyedVectors.load_word2vec_format(twitter_embedding_path, binary=False, fvocab=twitter_vocab_path) print('type(x_vectors)', type(x_vectors)) print('type(x_vectors.vocab)', type(x_vectors.vocab)) print('type(x_vectors.vocab.keys())', type(x_vectors.vocab.keys())) Content in ’twitter_embedding.emb’: 5120 64 BarackObama -0.079930 0.106491 -0.075812 -0.026447 … mashable 0.046692 -0.038019 -0.055519 … … Content in ’twitter_model.vocab’: BarackObama 3475971 mashable 2668606 JonahLupton 2515250 instagram 2359886 TheEllenShow 2292545 cnnbrk 2157283 nytimes 2141588 foursquare 2021352 … Write the embeddings into file for writing the embeddings into file ref code patch:

READ MORE

keras及神经网络,以简单实例入门

由浅入深,深入浅出。还给你reference了很多,如果你想要更多。 迄今为止看到最棒的,最值得follow的入门tutorial: https://realpython.com/python-keras-text-classification/ ↑由浅入深,深入浅出。还给你reference了很多,如果你想要更多。 重点中的重点,得记录一下,好多csdn的blog都不负责地只贴图,不讲咋看图: You can see that we have trained our model for too long since the training set reached 100% accuracy. A good way to see when the model starts overfitting is when the loss of the validation data starts rising again. This tends to be a good point to stop the model. You can see this around 20-40 epochs in this training. 机器翻译:您可以看到,自从训练集达到100%的准确率以后,我们对模型的训练时间太长了。查看模型何时开始过拟合的一个好方法是验证数据的损失何时开始再次上升。这往往是一个停止模型的好点。你可以在这个训练中看到20-40个迭代周期。 这也很重要: 扩展阅读: 一个官方IMDB数据集上的教程:Keras with IMDB 知乎:AI从入门到放弃-BP神经网络算法推导及代码实现笔记

READ MORE