编程
ASKCOS
AI4Sicence研究员,如有合作请通过站内信。
展开
-
如何在机器学习训练平台运行指定的conda环境
在对应的脚本sh加入,conda环境下的python。原创 2022-08-18 20:52:21 · 429 阅读 · 0 评论 -
wegt | 批量下载url下的文件
wget --user user --password pass -r -np -nH -R index.html http://url/including/files/you/want/to/download/各个参数的含义:-r : 遍历所有子目录-np : 不到上一层子目录去-nH : 不要将文件保存到主机名文件夹-R index.html : 不下载 index.html 文件-user 用户名-password 密码这里是引用这里是引用...原创 2022-05-19 14:21:10 · 723 阅读 · 0 评论 -
torch | 矩阵乘法@点积和*哈达玛积
import numpy as npa = np.array(range(4)).reshape(2,2)b = np.array(range(4,8)).reshape(2,2)print(a)print(b)print(a*b) #哈达玛积print(a@b) #点积[[0 1][2 3]][[4 5][6 7]][[ 0 5][12 21]][[ 6 7][26 31]]Process finished with exit code 0...原创 2022-01-13 11:29:55 · 1247 阅读 · 0 评论 -
根据具体时间给AI模型命名
import datetimemodel_name = datetime.datetime.now().__format__('%Y_%m%d_%H%M')原创 2022-01-11 11:35:52 · 370 阅读 · 0 评论 -
flask api并发功能加上processes为True
app.run(host="0.0.0.0",port=5000, processes=True)原创 2021-11-24 00:05:53 · 919 阅读 · 0 评论 -
AWS | sagemaker codecommit连接
https://aws.amazon.com/cn/blogs/publicsector/how-to-manage-amazon-sagemaker-code-aws-codecommit/原创 2021-11-11 23:09:30 · 97 阅读 · 0 评论 -
linux & flask | 接口保持在后台一直运行
防止IDE或者terminal关闭后,接口暂停nohup python run.py >/dev/null 2>&1 &原创 2021-11-10 14:33:00 · 1666 阅读 · 0 评论 -
python | 打开.pkl.gz文件
import gzipimport picklewith gzip.open("./abc.pkl.gz",'rb') as f: data = pickle.load(f)原创 2021-07-09 10:59:17 · 871 阅读 · 0 评论 -
linux | 批量杀掉进程
#列出了当前主机中运行的进程中包含firefox关键字的进程ps -ef | grep firefox | grep -v grep #列出了要kill掉这些进程的命令,并将之打印在了屏幕上ps -ef | grep firefox | grep -v grep | awk '{print "kill -9 "$2}'#后面加上|sh后,则执行这些命令,进而杀掉了这些进程ps -ef | grep firefox | grep -v grep | awk '{print "kill -9原创 2021-07-08 16:50:41 · 91 阅读 · 0 评论 -
python | 多进程计算
def hhh(i): return i ** 3 pool = Pool(processes=3)h1 = pool.map(hhh, iterable=[1, 2, 3, 4])print(h1)[1, 8, 27, 64]h2 = pool.map_async(hhh, iterable=[1, 2, 3, 4])for i in h2.get(): print(i)182764import timefrom multiprocessing原创 2021-03-18 19:17:20 · 173 阅读 · 0 评论 -
java | scanner输入数组元素
public static void main (String[] args){ Scanner input = new Scanner(System.in); double[] numbers = new double[10]; for (int i = 0; i < numbers.length; i++) { System.out....原创 2018-11-22 07:31:22 · 12604 阅读 · 0 评论 -
python | 程序运行log输出到文件
f_result=open('result.txt', 'w') sys.stdout=f_result原创 2021-02-16 14:38:53 · 655 阅读 · 2 评论 -
python | 保存log
import loggingdef run(): logging.info('hello world')def setup_logger(fname=None, silent=False): if fname is None: logging.basicConfig( level=logging.INFO if not silent else logging.CRITICAL, format='%(name)-12s:原创 2020-12-08 10:57:41 · 805 阅读 · 1 评论 -
在多维数组中遍历其中的单个元素 --python
multi_dim_list = [[[1,2,3,4],[5,6,7,8]],[[9,10,11,12],[13,14,15,16]]]item = []def traverse(lists): for i in lists: if type(i) != list: item.append(i) else: ...原创 2020-02-24 14:12:48 · 1449 阅读 · 0 评论 -
基于图的从头输出的深度优先遍历 --python
class DFS: def __init__(self, start): self.path = [start] self.path_list = [] def func(self, graph, node): if node not in graph.keys(): print(self.path) ...原创 2020-02-20 15:22:59 · 185 阅读 · 0 评论 -
pandas将Dataframe某一列设置标签
df.set_index(["Column"], inplace=True)原创 2019-10-31 13:45:11 · 6681 阅读 · 0 评论 -
将字母转换为0到25 python
pos = ord('c') - ord('a')pos的值为2用两个字母的unicode相减的到index原创 2019-10-26 23:39:29 · 689 阅读 · 0 评论 -
二分查找 python
def binary_search(arr , target): r = len(arr) - 1 l = 0 while l <= r: m = (l + r) // 2 if arr[m] == target: return m if arr[m] > target: ...原创 2019-09-06 20:51:19 · 100 阅读 · 0 评论 -
冒泡排序 python
def bubble_sort(nums): for i in range(len(nums)): for j in range(len(nums)-i-1): if nums[j]>nums[j+1]: nums[j], nums[j+1] = nums[j+1],nums[j] return nums...原创 2019-09-06 20:37:49 · 104 阅读 · 0 评论 -
(Leetcode 142)Linked List Cycle (II) (快慢指针详解)
# Definition for singly-linked list.# class ListNode(object):# def __init__(self, x):# self.val = x# self.next = Noneclass Solution(object): def detectCycle(self, head):...原创 2019-06-09 23:10:31 · 69 阅读 · 0 评论 -
java | 抽象和接口的讲解与区别
首先举个例子:动物 、狗、猫用抽象方法,猫和狗属于动物有层次关系;飞机、石头、子弹、公鸡没有继承关系,他们都能“飞”,定义一个“飞”的接口,都能“攻击”,定义一个“攻击接口”。为什么要抽象类?如何定义抽象类抽象类是一种模板模式。抽象类为所有子类提供了一个通用的模板,子类可以在这个模板上进行扩展。通过抽象类,可以避免子类设计的随意性。 通过抽象类,我们可以做到严格限制子类的设计(必须实现...原创 2019-04-26 23:21:38 · 92 阅读 · 0 评论