
python
likyoo
You can visit https://github.com/likyoo for more information.
展开
-
Anaconda换源
清华源根据官方手册中的说明Anaconda 安装包可以到 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 下载。TUNA 提供了 Anaconda 仓库与第三方源(conda-forge、msys2、pytorch等,查看完整列表)的镜像,各系统都可以通过修改用户目录下的 .condarc 文件。Windows 用户无法...原创 2020-03-30 17:43:46 · 8382 阅读 · 0 评论 -
pytorch 张量的操作
Tensor Operation1. 张量拼接与切分torch.cat():将张量的维度dim进行拼接,不会扩张张量的维度 如dim=0,则两个向量将在第0维进行拼接:(3,4)concat(3,4)-->(6,4)torch.stack():在新创建的维度dim上进行拼接 如dim=0,则(3,...原创 2020-01-14 13:53:37 · 785 阅读 · 0 评论 -
pytorch tensor创建
create tensor1. torch.tensor():从data创建tensordata可以是list,numpy;dtype默认与data一致。2. torch.from_numpy(ndarray):从numpy创建tensor这里创建的tensor与原ndarray共享内存,一个改变另一个就会改变。3.torch.zeros():依size创建全0张量...原创 2020-01-13 21:22:01 · 1254 阅读 · 0 评论 -
《ML with python cookbook》: Loading Data
1.Loading a CSV Fileimport pandas as pdpath = 'F:/pycharmFile/input/train_data.csv'dataframe = pd.read_csv(path)dataframe.head(2)notes: 1. see how a dataset is structured beforehand ...原创 2019-05-19 23:06:58 · 193 阅读 · 0 评论 -
Leetcode Medium 5 Letter Combinations of a Phone Number
不用递归 class Solution: def letterCombinations(self, digits): dic = {'2':'abc', '3':'def','4':'ghi', '5':'jkl', '6':'mno', '7':'pqrs', '8':'tuv', '9':'wxyz'} if not digits: ...原创 2019-01-22 17:16:48 · 123 阅读 · 0 评论 -
Leetcode Hard 0 Regular Expression Matching
emmmm.......class Solution: def isMatch(self, s, p): import re value = re.match(p, s) if value == None or value.group(0) != s: return False else: ...原创 2019-01-15 22:00:58 · 181 阅读 · 0 评论 -
Leetcode Medium 4 Container With Most Water
class Solution: def maxArea(self, height): max_pool = 0 i, j = 0, len(height)-1 while i < j: if height[i] < height[j]: max_pool = max(max...原创 2019-01-14 22:29:15 · 123 阅读 · 0 评论 -
Leetcode Easy 2 Roman to Integer
class Solution: def romanToInt(self, s): # if s == '': # return 0 def compare(a, b): if dic[a] >= dic[b]: return dic[a] else...原创 2019-01-18 23:57:37 · 121 阅读 · 0 评论 -
Leetcode Medium 3 Longest Substring Without Repeating Characters
用滑动窗口 class Solution: def lengthOfLongestSubstring(self, s): i, j, ans = 0, 0, 0 len_s = len(s) max_str = '' while j < len_s: if not s[j] in max_s...原创 2019-01-13 23:47:56 · 115 阅读 · 0 评论 -
Leetcode Medium 2 String to Integer (atoi)
class Solution: def myAtoi(self, str): s = '' str = str.lstrip() for i in range(len(str)): if str[i].isdigit() or ((str[i] == '+' or str[i] == '-') and i == 0)...原创 2019-01-12 23:29:54 · 121 阅读 · 0 评论 -
Leetcode Easy 1 Reverse Integer
class Solution: def reverse(self, x): if x >= 0: s = str(x) s = s[::-1] else: s = str(-x) s = s[::-1] s = '-' + s ...原创 2019-01-12 21:41:08 · 147 阅读 · 0 评论 -
Keras--mnist
1. activation function : sigmoid loss function : mean squared error optimizer : SGDimport numpy as npfrom keras.models import Sequentialfrom keras.layers.core import Dense, Dropout, Ac...原创 2018-12-08 23:37:50 · 197 阅读 · 0 评论 -
numpy学习笔记
官方文档内容: numpy.prod numpy.prod(a,axis = None,dtype = None,out = None,keepdims = <no value>,initial = <no value> )返回给定轴上的数组元素的乘积。 numpy.transposenumpy.transpose(a,axes =...原创 2018-11-28 16:07:42 · 190 阅读 · 0 评论 -
如何使用jupyter notebook
最近学习时用到了jupyter notebook,这里简单说一下jupyter notebook的基础用法。首先打开cmd,安装 jupyterpip install jupyter 下载完成后。键入jupyter notebook执行。 之后他会自动打开一个端口,并打开你的浏览器。界面如下选择index.ipynb,进入引导页面。然后可以如图新建文件...原创 2018-10-23 21:41:59 · 1386 阅读 · 0 评论 -
python--爬取知乎中的图片
首先,我们查看一下知乎的robots协议。User-agent: *Disallow: /知乎是不允许爬取其根目录的。但是,我们只是用于实验,而且访问频率和正常访问差距不大,所以可以爬取。先明确目的:对手动输入的网址进行解析 把爬取到的图片保存到指定目录__author__ = '_liky'import requestsfrom bs4 import Beau...原创 2018-10-10 12:37:55 · 1499 阅读 · 1 评论 -
python——解决ccf最小差值题
问题描述试题编号: 201712-1 试题名称: 最小差值 时间限制: 1.0s 内存限制: 256.0MB 问题描述: 问题描述 给定n个数,请找出其中相差(差的绝对值)最小的两个数,输出它们的差值的绝对值。 输入格式 输入第一行包含一个整数n。 第二行包含n个正整数,相邻整数之间使用一个空格分隔...原创 2018-09-18 09:22:40 · 562 阅读 · 0 评论