摘要: NO46. 全排列#考察回溯,[1,2,3,4]->1+[2,3,4]->1+2+[3,4] # ->1+3+[2,4]... # 之后重置往前返回 #也类似深度优先遍历,把每层的最深一层找到然后返回,再重复操作 class Solution: def permute(self, nums: Lis 阅读全文
posted @ 2022-07-22 20:55 是冰美式诶 阅读(28) 评论(0) 推荐(0)
摘要: #和之前通配符匹配很像,dp的思路 class Solution: def isMatch(self, s: str, p: str) -> bool: vertical = len(p)+1 #纵向的长度,由于有初始start因此加一 level = len(s)+1 if set(p) == { 阅读全文
posted @ 2022-07-21 17:22 是冰美式诶 阅读(25) 评论(0) 推荐(0)
摘要: #最近的算法都是考查思维而不是特定算法,值得一试 #按层 class Solution: def trap(self, height: List[int]) -> int: n=len(height) left,right=0,n-1 tmp,high=0,1 while(left<=right): 阅读全文
posted @ 2022-07-21 17:19 是冰美式诶 阅读(78) 评论(0) 推荐(0)
摘要: #偷巧法 #正整数是指大于0的数,那想到添加参数0,然后进行比较 #如果是连续的就返回最后一个值,否则返回跳跃的那个值 class Solution: def firstMissingPositive(self, nums: List[int]) -> int: nums.append(0) num 阅读全文
posted @ 2022-07-21 17:13 是冰美式诶 阅读(27) 评论(0) 推荐(0)
摘要: #导入相关的库 import tensorflow as tf import os import numpy as np import matplotlib.pyplot as plt <!-- 打标签 设定猫为0,狗为1 打乱数据集,细节如下 --> #读取数据集中所有图片的路径和标签 def g 阅读全文
posted @ 2022-07-20 21:21 是冰美式诶 阅读(185) 评论(0) 推荐(0)
摘要: import tensorflow.compat.v1 as tf tf.disable_v2_behavior() import numpy as np from matplotlib import pyplot as plt #添加层 def add_layer(inputs, in_size, 阅读全文
posted @ 2022-07-20 21:20 是冰美式诶 阅读(26) 评论(0) 推荐(0)
摘要: 激励函数运行时激活神经网络中某一部分神经元,将激活信息向后传入下一层的神经系统 含有如下激励函数: tf.nn.sigmoid:将实数压缩到0到1之间,一般只在二分类的最后输出层使用。主要缺陷为存在梯度消失问题,计算复杂度高,输出不以0为中心。 tf.nn.softmax:sigmoid的多分类扩展 阅读全文
posted @ 2022-07-20 21:19 是冰美式诶 阅读(46) 评论(0) 推荐(0)
摘要: class Solution: def combinationSum2(self, candidates: List[int], target: int) -> List[List[int]]: res = [] path = [] n = len(candidates) candidates.so 阅读全文
posted @ 2022-07-19 21:45 是冰美式诶 阅读(45) 评论(0) 推荐(0)
摘要: #本次采用pytorch实现 #探究房屋状况的俩个因素,房龄和面积 #公式 price = w(area)*area+w(age)*age+b #损失函数:用于衡量价格预测值与真实值之间的误差,通常我们会选取一个非负数作为误差,且数值越小表示误差越小 #优化函数 ->直接用公式表达出来。这类解叫作解 阅读全文
posted @ 2022-07-19 21:43 是冰美式诶 阅读(44) 评论(0) 推荐(0)
摘要: #前者为Variable的案例 #后者为Session import tensorflow as tf tf.compat.v1.disable_eager_execution() state = tf.Variable(0, name='counter') # 定义常量 one one = tf. 阅读全文
posted @ 2022-07-18 21:20 是冰美式诶 阅读(45) 评论(0) 推荐(0)