- 博客(33)
- 资源 (2)
- 收藏
- 关注
原创 吴恩达机器学习 课后作业 13.2 k-means pytorch实现
听说最近字节面试经常让手撕k-means代码,那不如就用pytorch撕一撕吧。之前学过的都忘得差不多了,参考了两个网上的代码,话不多说上代码import torchimport torch.nn as nnfrom scipy.io import loadmatimport numpy as nproot_path = '../machine-learning-ex7/ex7/'data_file_path = root_path + 'ex7data2.mat'data_fi.
2021-03-24 21:01:45
809
1
原创 COMP 527 - 2019 - CA Assignment 1 Data Classification Implementing Perceptron algorithm
Assessment InformationAssignment Number 1 (of 2)Weighting 12%Assignment Circulated 28th January 2019Deadline 5th March 2018, 15:00 UK Time (UTC)Submission Mode Electronic via Departmental submission systemLearning outcome assessed (1) A critica
2021-03-19 16:09:39
300
1
原创 plt.figture总结
def use_svg_display(): # 用矢量图显示 display.set_matplotlib_formats('svg')def set_figsize(figsize=(3.5, 2.5)): use_svg_display() # 设置图的尺寸 plt.rcParams['figure.figsize'] = figsizeset_figsize()#设置图片尺寸及显示方式的封装函数plt.rcParams['figure.fig.
2020-11-02 15:06:22
965
2
原创 背包问题整理
一、0-1背包问题POJ3624代码:1、传统0-1背包(space limited)#include <bits/stdc++.h>using namespace std;const int maxn=3410;const int maxv=12890;int w[maxn];int v[maxn];int dp[maxn][maxv];int n,m;int main(){ cin>>n>>m; int i,
2020-09-19 16:16:29
141
原创 算法笔记-12.1-字符串hash进阶
代码如下:#include<bits/stdc++.h>using namespace std;const int maxn=1010;typedef long long LL;const LL MOD = 1000000007;const LL P = 10000019;LL powp[maxn],h1[maxn]={0},h2[maxn]={0}; //(p^i)%mod str1,str2的hashvector< pair<int,int> ..
2020-09-09 15:30:49
141
原创 算法笔记-BFS
解决思路:代码实现:#include<bits/stdc++.h>using namespace std;int m,n,ans=0;int a[20][20]={0};bool b[20][20]={0};int nx[4]={0,0,1,-1};int ny[4]={1,-1,0,0};bool judge(int x1,int y1){ if(x1<0||x1>m||y1<0||y1>n) return fals..
2020-08-14 11:34:01
196
原创 小甲鱼python P1-P10
首先是一些笔记帮助我记忆回顾课堂知识:input函数返回类型是字符串,这是我在编程中总是遇到报错的罪魁祸首 生成随机数的方法:random模块中的randint(a,b)函数,返回一个a,b之间的随机整数 输入长字符分行的方法:用三个引号:"""blabla""" 转义字符: "/" 类型转换:float->int:截取(砍掉小数点后面的部分5.99->5) 类型检查函数...
2020-02-29 22:49:51
222
原创 每天一道python编程-洛谷P1003
u1s1,虽然学过C++的同学都说python简单,但是真正写起来题才发现自己可能过于自信了,鉴于python里面用list取代了数组,但是多维数组的实现就很麻烦了,,,,,况且python的输入input函数相比于C++的cin也不知道复杂了多少,光是循环输入数组数据就令我头疼了好久。。。。。卡在这道题上有两天了,实在没什么进展还很烦躁,最后不得不求助了大师兄才得到了ac代码,现在就来好好的...
2020-02-25 18:34:56
787
原创 每天一道python编程-洛谷P1009
这道题求阶乘之和,考察精度,但是python自带高精度所以写起来几乎没有难度,是一道水题n=input()n=int(n)s=0for i in range(1,n+1): m=1 for j in range(2,i+1): m=m*j s += mprint(s)...
2020-02-21 15:10:04
382
原创 每天一道python编程-洛谷P1008
首先是之前用c语言写过的一个版本用到了乘1002003的方法:#include <bits/stdc++.h>using namespace std;int main(){ long long x; int i,t=0,b,c,m=0,j; bool cf=false; int a[9]={0}; for(i=123;i<=329;i++) { x...
2020-02-21 14:51:46
420
原创 每天一道python编程-洛谷P1001
s=input().split()print(int(s[0]) + int(s[1]))这里问题的关键在于如何接收输入用空格分隔的两个整数解决方法为input().split()函数,具体如下:https://www.runoob.com/python/att-string-split.html...
2020-02-20 16:42:36
849
原创 每天一道python编程之-洛谷P1000
a=""" ******** ************ ####....#. #..###.....##.... ###.......###### ### ### .........
2020-02-20 13:01:52
649
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人