自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(302)
  • 收藏
  • 关注

原创 关于学习Python的一点学习总结(16->popitem()->sedefault()->update()->values())

37popitem():随机的弹出字典中的一个字典项 >>> array={'first':'one','second':'two','third':'three'} >>> array.popitem() ('third', 'three') >>> array {'first': 'one', 'second': 'two'}---------------------------------------------

2021-03-31 23:56:35 54

原创 关于学习Python的一点学习总结(15)

34.items:返回一个包含所有字典的列表 >>> array={'first':'one','second':'two','third':'three'} >>> array.items() dict_items([('first', 'one'), ('second', 'two'), ('third', 'three')]) >>> it=array.items() >>> len(it)

2021-03-31 23:56:25 58

原创 Himmelblau函数优化实战

#f(x,y)=(x**2+y-11)**2+(x+y**2-7)**2import tensorflow as tfimport numpy as npimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Ddef himmelblau(x):#函数实现,传入参数x为两个元素的list return (x[0]**2+x[1]-11)**2+(x[0]+x[1]**2-7)**2x=np.arang

2021-03-31 23:46:14 420

原创 关于学习tf.random.normal()和tf.random.uniform()的一点小总结

tf.random.normal(shape,mean=0.0,stddev=1.0)-正态分布1.shape-可以创建形状为shape的数组2.mean-均值3.stddev-标准差,正态分布N(mean,stddev^2) 例如:import tensorflow as tf import numpy as np x=tf.random.normal([2,3],stddev=0.1) print(x)

2021-03-31 20:09:15 754

原创 关于全连接层梯度的链式法则

import tensorflow as tfimport numpy as np#构建待优化变量x=tf.constant([1.])w1=tf.constant([2.])b1=tf.constant([1.])w2=tf.constant([2.])b2=tf.constant([1.])#构建梯度记录器with tf.GradientTape(persistent=True) as tape: #tf.Variable类型的张量需要人为的设置记录梯度信息 tape.

2021-03-31 09:27:05 426

原创 关于学习Python的一点学习总结(14->换一种方法创建字典->访问字典)

32.创建新字典:>>> {}.fromkeys(['first','second']) {'first': None, 'second': None}----------------------------------------------------------------------------------------------33.访问字典:get() >>> array={} >>> print(array['nam

2021-03-31 00:02:40 61

原创 关于学习Python的一点学习总结(13->浅复制和深复制)

31.浅复制:copy()>>> x={'first':'Tom','second':'Jon','third':['one','two','three']} >>> y=x.copy() >>> y['username']='you' >>> y['third'].remove('one') >>> y {'first': 'Tom', 'second': 'Jon', 't

2021-03-31 00:02:30 129

原创 关于学习Python的一点学习总结(12->字典相关操作)

30.删除字典中的所有字典项:clear() >>> d={} >>> d['name']=45 >>> d['age']=67 >>> d {'name': 45, 'age': 67} >>> result=d.clear() >>> d {} >>> print(d) {} &

2021-03-31 00:02:22 85

原创 关于ValueError: Unknown projection ‘3d‘报错的解决方法

加入这个就可以了:加入:from mpl_toolkits.mplot3d import Axes3Dimport tensorflow as tfimport matplotlibfrom matplotlib import pyplot as plt#导入三维坐标支持from mpl_toolkits.mplot3d import Axes3Dimport numpy as npx=tf.linspace(-8.,8,100)#设置x轴的采样点y=tf.linspace(-8.,8,

2021-03-31 00:02:10 2673 1

原创 关于TypeError: ‘function‘ object is not subscriptable 报错的解决方法

在使用这个的时候出了问题:b1=tf.Variable(tf.zeros([256])tf.zeros[256]应该加括号->tf.zeros([256])张量方式实现全连接层import tensorflow as tfimport matplotlib.pyplot as pltx=tf.random.normal([2,784])w1=tf.Variable(tf.random.truncated_normal([784,256],stddev=0.1))b1=tf.Variab

2021-03-31 00:02:00 486

原创 关于AttributeError: module ‘numpy‘ has no attribute ‘integer‘的解决方法

重装numpy():pip uninstall numpy(卸载numpy)pip install -U numpy(重装)但是我在卸载之后又重装还是出现这样的错误,因为我之前把那个tensorflow的版本升级到了2.4.1,我又把那个tensorflow卸载(pip uninstall tensorflow)之后重装tensorflow2.0.0(pip install tensorflow==2.0.0 -i https://pypi.tuna.tsinghua.edu.cn/simple)的

2021-03-30 23:45:06 4040

原创 关于TypeError: ‘numpy.ndarray‘ object is not callable报错

报错的代码:import tensorflow as tfimport numpy as npdef sigmoid(x): return 1/(1+np.exp(-x))def derivative(x): return sigmoid(x)(1-sigmoid(x))x=tf.constant([2.,1.,0.1])out=derivative(x)print(out)修改后的代码:import tensorflow as tfimport numpy as

2021-03-30 23:35:14 1698

原创 关于学习Python的一点学习总结(11->字典的应用)

29.一个简单的数据库(字典的应用) people={'Alice':{'phone':'2341','addr':'Foo drive 23'}, 'Beth':{'phone':'9102','addr':'Bar street 42'}, 'Cecil':{'phone':'3158','addr':'Bar avenue90'} } labels={ 'phone':'phone number', 'addr':'addres

2021-03-30 00:08:26 91

原创 关于学习Python的一点学习总结(10->设置字符串格式)

28.设置字符串的格式:1.转换说明符:%s>>> name="hello ,%s,%s,world!%s to china" >>> values=('go','go','welcome') >>> name%values'hello ,go,go,world!welcome to china'2.替换字段在没有名称的情况下:每个字段使用花括号括起来. >>> name="{},{},go {}".

2021-03-30 00:08:18 161

原创 习题6-7 简单计算器 (20 分)

#include<stdio.h>#include<math.h>int main(){ char ch; int temp1=0; int sum=0; int flag=1; scanf("%d",&sum); while(scanf("%c",&ch)!=EOF){ if(ch=='=')break; scanf("%d",&temp1); if(ch=='+'){ sum+=temp1; }else if(ch==

2021-03-30 00:08:07 174

原创 练习7-11 字符串逆序 (15 分)

#include<stdio.h>#include<math.h>#include<string.h>int main(){ char s[105]; while(gets(s)){ int len=strlen(s); for(int i=len-1;i>=0;i--){ printf("%c",s[i]); } printf("\n"); } return 0;}

2021-03-30 00:07:56 539

原创 习题7-1 选择法排序 (20 分)

方法一:直接插入排序#include<stdio.h>#include<math.h>#include<string.h>int main(){ int a[105]; int n; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d",&a[i]); } for(int i=1;i<n;i++){ int temp=a[i]; int j=i; while(j&g

2021-03-30 00:07:42 352

原创 习题7-2 求一批整数中出现最多的个位数字 (20 分)

#include<stdio.h>#include<math.h>#define maxx 105int n;int main(){ int p[maxx]; for(int i=0;i<=10;i++){ p[i]=0; } scanf("%d",&n); for(int i=0;i<n;i++){ int x; scanf("%d",&x); while(x!=0){ int digit=x%10; p[d

2021-03-30 00:03:30 60

原创 习题7-3 判断上三角矩阵 (15 分)

#include<stdio.h>#include<math.h>#define maxx 105int n;int main(){ int a[maxx][maxx]; int t; scanf("%d",&t); while(t--){ scanf("%d",&n); for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ scanf("%d",&a[i][j]); }

2021-03-30 00:03:20 117

原创 习题7-4 求矩阵各行元素之和 (15 分)

#include<stdio.h>#include<math.h>#define maxx 105int n;int main(){ int a[maxx][maxx]; int n,m; while(scanf("%d %d",&n,&m)!=EOF){ for(int i=0;i<n;i++){ for(int j=0;j<m;j++){ scanf("%d",&a[i][j]); } } for(

2021-03-30 00:03:04 146

原创 关于学习Python的一点学习总结(9->字典创建及相关操作)

27.创建和使用字典:字典由键及其相应的值组成,这种键值对称为项(item)方法一: >>> name={'Hongkong':'45','shanghai':'67','guizhou':'89'} >>> name {'Hongkong': '45', 'shanghai': '67', 'guizhou': '89'}方法二: >>> item={('hongkong','45'

2021-03-29 07:37:26 133

原创 关于学习Python的一点学习总结(8->strip()->isspace())

25.strip():将字符串开头和末尾的空白(但不包括中间的空白)删除,并返回删除后的结果。 1. >>> array=' hello ,world! ' >>> array.strip() 'hello ,world!'2.还可以删除指定的字符 >>> array='###hello ,world!!!%%%'.strip('#%') >>> array 'hello ,world!!!'

2021-03-29 07:37:20 132

原创 习题7-5 找鞍点 (20 分)

#include<stdio.h>#include<math.h>#define maxx 105int n;int main(){ int a[maxx][maxx]; int n,m; int b[maxx]; while(scanf("%d",&n)!=EOF){ for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ scanf("%d",&a[i][j]); } }

2021-03-29 07:37:05 185

原创 习题7-6 统计大写辅音字母 (15 分)

方法一:#include<stdio.h>#include<math.h>#include<string.h>#define maxx 105int n;int main(){ char s[maxx]; int n,m; int b[maxx]; while(gets(s)){ int count=0; int len=strlen(s); for(int i=0;i<len;i++){ if(s[i]>='A'&

2021-03-29 07:36:58 91

原创 习题8-7 字符串排序 (20 分)

#include<stdio.h>#include<math.h>#include<string.h>#define maxx 105int n;int main(){ char s[maxx][maxx]; for(int i=0;i<5;i++){ scanf("%s",&s[i]); } char temp[maxx]; for(int i=0;i<5;i++){ for(int j=i+1;j&lt

2021-03-29 07:36:51 106

原创 习题8-10 输出学生成绩 (20 分)

#include<stdio.h>#include<math.h>#include<string.h>#define maxx 1005int n;struct node{ double scores;}num[maxx];int main(){ int n; scanf("%d",&n); double max=0; double min=101; for(int i=0;i<n;i++){ scanf("%lf"

2021-03-29 07:36:44 150

原创 习题9-1 时间换算 (15 分)

#include<stdio.h>#include<math.h>#include<string.h>#define maxx 1005int n;int main(){ int h,m,s; scanf("%d:%d:%d",&h,&m,&s); int second; scanf("%d",&second); int m1=(second+s)/60; int st=(second+s)%60; int ht=(

2021-03-29 07:36:35 104

原创 习题9-3 平面向量加法 (15 分)

#include<stdio.h>#include<math.h>#include<string.h>#define maxx 1005int n;int main(){ double x,y; double x1,y1; scanf("%lf %lf %lf %lf",&x,&y,&x1,&y1); double x2=x+x1; double y2=y+y1; if(fabs(x2)<0.05)x2=fabs

2021-03-29 07:36:28 137

原创 习题9-4 查找书籍 (20 分)

#include<stdio.h>#include<math.h>#include<string.h>#define maxx 1005int n;struct node{ double cost; char s[maxx];}num[maxx];int main(){ int n; scanf("%d",&n); int max=0; int min=0; for(int i=0;i<n;i++){ getchar();

2021-03-29 07:36:20 107

原创 习题9-5 通讯录排序 (20 分)

#include<stdio.h>#include<math.h>#include<string.h>#define maxx 1005int n;struct node{ char name[maxx]; int id; char number[maxx];};int main(){ int n; scanf("%d",&n); struct node num[maxx]; for(int i=0;i<n;i++){ sca

2021-03-29 07:36:13 118

原创 习题6-8 统计一行文本的单词个数 (15 分)

#include<stdio.h>#include<math.h>#include<string.h>int main(){ char s[1005]; while(gets(s)){ int len=strlen(s); int count=0; int i=0; while(s[i]==' '){ i++; } while(s[i]!='\0'){ if(s[i]!=' '){ count++; while

2021-03-28 08:36:21 114

原创 关于学习Python的一点学习总结(7->相关字符串操作)

24.字符串:字符串不可进行元素的赋值和切片赋值1.center():通过在两边添加填充字符(默认为空格)让字符串居中。 >>> 'hello,world !welcome to china'.center(39) ' hello,world !welcome to china ' >>> 'hello,world !welcome to china'.center(39,'*') '*****hello,world !wel

2021-03-28 08:36:04 125

原创 关于学习Python的一点学习总结(6->元组)

23.元组:不可修改的列表1.将一些值用逗号分隔,自动创建一个元组: >>> 5,6,7,8,9,89 (5, 6, 7, 8, 9, 89) 2.空元组用两个不包含任何内容的圆括号表示: >>> () () 3.当元组只有一个元素时,元素的末尾也要添加分隔符: >>> 99, (99,) 4.有分隔符和没有分隔符的区别: >>> 2*(3+4) 14

2021-03-28 08:35:55 110

原创 练习7-2 求最大值及其下标 (20 分)

#include<stdio.h>#include<math.h>#include<string.h>int main(){ int a[105]; int n; while(scanf("%d",&n)!=EOF){ int index=0; for(int i=0;i<n;i++){ scanf("%d",&a[i]); } int max=a[0]; for(int i=1;i<n;i++){

2021-03-28 08:35:31 113

原创 练习7-3 将数组中的数逆序存放 (20 分)

#include<stdio.h>#include<math.h>#include<string.h>int main(){ int a[105]; int n; while(scanf("%d",&n)!=EOF){ int index=0; for(int i=0;i<n;i++){ scanf("%d",&a[i]); } for(int i=n-1;i>0;i--){ printf("%d ",a

2021-03-28 08:35:22 309

原创 练习7-4 找出不是两个数组共有的元素 (20 分)

#include<stdio.h>#include<math.h>#include<string.h>int main(){ int a[105]; int b[105]; int n,m; scanf("%d",&n); int index=0; for(int i=0;i<n;i++){ scanf("%d",&a[i]); } scanf("%d",&m); for(int i=0;i<m;i++){

2021-03-28 08:35:15 195

原创 练习7-7 矩阵运算 (20 分)

#include<stdio.h>#include<math.h>#include<string.h>int main(){ int a[105][105]; int b[105]; int n,m; scanf("%d",&n); int index=0; int sum=0; for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ scanf("%d",&a[i][j]);

2021-03-28 08:35:06 143

原创 练习7-8 方阵循环右移 (20 分)

#include<stdio.h>#include<math.h>#include<string.h>int main(){ int a[105][105]; int b[105][105]; int n,m; scanf("%d %d",&n,&m); int index=0; int sum=0; for(int i=0;i<m;i++){ for(int j=0;j<m;j++){ scanf("%d",&a

2021-03-28 08:34:57 74

原创 练习7-9 计算天数 (15 分)

#include<stdio.h>#include<math.h>#include<string.h>int lineyear(int n){ if((n%4==0&&n%100!=0)||(n%400==0)){ return 1; }else{ return 0; }}int main(){ int month[13]={0,31,28,31,30,31,30,31,31,30,31,30}; int b[105][105]

2021-03-28 08:34:48 148

原创 练习7-10 查找指定字符 (15 分)

#include<stdio.h>#include<math.h>#include<string.h>int main(){ int index=0; char s[105]; char ch; scanf("%c",&ch); getchar(); gets(s); int flag=0; for(int i=0;s[i]!='\0';i++){ if(s[i]==ch){ index=i; flag=1; } }

2021-03-28 08:34:40 98

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除