ARTS-WEEK 1

动机

首先解释一下什么是ARTS?

关于ARTS打卡计划:What is ARTS?

也就是说: Algorithm、Review、Tip、Share 简称ARTS,其中

  1. Algorithm:每周至少做一个 leetcode 的算法题
  2. Review:阅读并点评至少一篇英文技术文章
  3. Tip:学习至少一个技术技巧
  4. Share:分享一篇有观点和思考的技术文章

根据耗子叔的解释,ARTS的全部动机是:

编程训练和算法学习
学习英文
总结和归纳在是常工作中所遇到的知识点
建立影响力,输出价值观

同时,将这些写下来是因为写作也是一种非常重要的技能,写作不仅仅可以帮我们组织我们的思路和语言,梳理我们的知识,更重要的是写作其实是一种自己对自己的思考,同时还可以很容易地扩散并引入其它人的讨论、指正、批评,这对个人来说是非常重要的。
以上就是ARTS这个计划的内容和动机。
对于我而言,我在平时的学习过程中也有刻意锻炼提高自己的编程能力、英语能力,日常遇见的问题也有花时间(有时候是大把时间)去思考,去弄清楚,但是平时学过了也就学过了,解决了的问题也就解决了,大部分学到过的知识、做过的练习并没有特意地去梳理总结,也很少拿出来和他人分享。
正如耗子叔所说:

只有你开始自己思考,开始自己总结和归纳,开始找人交流讨论,开始践行,并开始对外输出,你才会掌握到真正的学习能力。

同时,考虑到到自己平时有跟同学讨论的知识点在脑海里的印象之深,我开始意识到自己目前学习方法上的缺点:缺少总结归纳、有输入,缺少输出;学习的效果自然不如有归纳总结和输出的好。于是,我决定加入ARTS打卡计划,开始以ARTS打卡的形式写点东西刻意地对自己所学的东西作个总结,分享自己学习上的收获,提高自己的技术能力和学习能力,记录自己的学习、成长历程,同时也会记录自己的一些想法和思考。欢迎阅读我的文字的朋友留言或者email我一起讨论。
以上是我参加ARTS打卡计划的动机。第一周在思考该怎么开始上想得比较多,说得也比较多,以后更新我尽量多写下面的干货,少罗嗦。


主要内容

由于我最近有接触python,对这门语法简单、功能强大的语言产生了浓厚的兴趣,目前已打算对python进行全面系统地学习,所以后面的内容主要会围绕python学习展开。另外我平时对物联网和人工智能两大领域的技术知识也有学习积累,今后也会持续学习人工智能和物联网相关知识和技术并在此分享。


ARTS

Algorithm:

LeetCode problem1: two sum
代码:

class Solution:
        def twoSum(self, nums: List[int], target: int) -> List[int]:#一次哈希
            if len(nums) <= 1:#输入的列表元素少于两个时,返回
                return False
            dic = {}#建立字典,键值为当前遍历的列表值与target的差值,值为当前遍历值的索引
            for i in range(len(nums)):#遍历列表nums,查询当前遍历值在不在字典dicz中
                if nums[i] in dic:#在,返回[dic[nums[i]],i]
                    return [dic[nums[i]], i]    
                else:#不在,字典中记录[差值:索引]
                    dic[target - nums[i]] = i

算法复杂度分析:

时间复杂度:O(n),遍历列表一次,最多遍历n次,每次遍历都要查询字典,每次查询时间复杂度为O(1).
空间复杂度:O(n),最多需要申请存储n个存储字典元素的空间.

此外,这道题还有两种方法,一种是暴力解法,直接遍历列表元素,每次遍历都查询列表中是否有等于当前遍历值与target差值的元素,每次查询时间复杂度为O(N);时间复杂度为O(n²),空间复杂度为O(1)。第二种方法是二次哈希,是对暴力解法中的查询时间复杂度进行优化,利用哈希表将其降为O(1),总时间复杂度为O(n),空间复杂度也是O(n)。

Review:

Article:Ten Things Python Programmers Should Know2013

作者首先建议想系统学习python的朋友应该熟悉以下几个网站:

然后列出了10个python基础却重要的概念:

1. python的版本号

  • Python versions are numbered as A.B.C., where the three letters represent (in decreasing order) important changes in the language. So, for instance, going from 2.7.3 to 2.7.4 means that the Python build made some minor bug fixes, while going from 2.xx to 3.xx represents a major change. Note the ‘x’ here, which is intentional; if a Python feature can apply to version number 2.7.C for any valid ‘C’ value, then we put in an ‘x’ and refer to Python 2.7.x. We can also omit the ‘x’ entirely and just use 2.7.
  • Python 3 is intentionally backwards incompatible. Backwards incompatibility was necessary in order to allow Python 3 to be more clear, concise and use additional features.
  • The difference between Python 2 and 3.

2. 使用python shell

总的来说,我们可以借助Python交互的shell进行探索式地编程,可以试着输入一些代码,然后马上获得解释器的反馈,而不必专门写一个脚本。

3. 使用 ‘os’ 和 ‘sys’ 模块

'sys’模块:
参考:

python之sys模块
sys.argv[]:Python中 sys.argv[]的用法简明解释

Sys.argv[ ]其实就是一个列表,里边的项为用户输入的参数,关键就是要明白这参数是从程序外部输入的,而非代码本身的什么地方,要想看到它的效果就应该将程序保存了,从外部来运行程序并给出参数。

'os’模块

os.system(command):通过os.system和subprocess.call()函数调用其他程序

Execute the command (a string) in a subshell.

4.列表推导(List Cprhension)

  • A list comprehension is a syntactic construct available in some programming languages for creating a list based on existing lists.(from wiki)
  • A list display yields a new list object. Its contents are specified by providing either a list of expressions or a list comprehension. When a comma-separated list of expressions is supplied, its elements are evaluated from left to right and placed into the list object in that order. When a list comprehension is supplied, it consists of a single expression followed by at least one for clause and zero or more for or if clauses. In this case, the elements of the new list are those that would be produced by considering each of the for or if clauses a block, nesting from left to right, and evaluating the expression to produce a list element each time the innermost block is reached [1].(from Python 2.7.5 documentation)

5. 切片

list1 = [0,1,2,3,4,5,6,7,8,9]
list2 = list1[start:stop:step]

Here, start is the index of the first element we want, stop is the index of the first element we don’t want (remember that in Python, ending indices are often exclusive rather than inclusive), and step represents the number kk where we take each kk-th value. It can be negative, too, which would indicate that we’re moving backwards through the list. Not all of these values are needed; if the step is omitted, it defaults to +1. And as the example earlier should make clear, if either start or stop are omitted, they should default to 0 and the length of the list, respectively.

…未完待续

Tip:

python读取dicom序列文件(pydicom实现):

import pydicom
    import os
    def load_scan(path):
        slices = [pydicom.filereader.dcmread(path + '/' + s) for s in os.listdir(path)]
        return slices

Share:

CSDN用户beyondma的分享:终于把AI换脸的原理搞清了

作者用简洁的语言阐述了AI换脸的原理和目前该技术的缺陷,表达了对这项技术会在信息安全上带来风险的担忧,同时作出了几点有参考价值的思考。

立个flag:后期对faceswap项目进行学习,实践AI换脸,敬请关注。

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值