自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 用einops直观任性操作Tensor,解决Patch Embedding问题

首先看一下原图:是一张jpg格式,512x512分辨率的图像,解码为RGB格式时,shape为[3, 512, 512]导入einops相关函数from einops import rearrange, reduce, repeat常用的就是这三个了,文末有官方教程地址,可全面学习,解决Transform中的第一步的Patch Embedding,rearrange(重新排列,重新整理)就足够了先增加一个b维度img = rearrange(img, 'c h w -> 1 c h w

2021-12-09 11:08:42 3427 2

原创 github无法访问,可以用这个镜像网站

如题,网址:https://hub.fastgit.org/我的网络可以进去,但是无法下载zip,不过还好可以看相关代码各位有需要的试试吧

2021-06-20 22:02:40 618

原创 使用PIL改变图像分辨率

这段代码是在这里看到的,人家写的已经非常简洁了,注释也非常到位了,我只不过加了个循环,可以批量改一下,有需要的直接用吧from PIL import Imageimport osdef ResizeImage(filein, fileout, scale): """ 改变图片大小 :param filein: 输入图片 :param fileout: 输出图片 :param width: 输出图片宽度 :param height: 输出图片宽度

2021-06-17 18:10:23 1854

原创 Python两个类中的变量跨类调用的一个方法:类实例化

​这是我在使用PyQt5(一个很方便好用的制作小软件的,可以说是Python的一个包吧,pip就可以使用)做一个小软件的时候,遇到的一个问题,因为如果是作为一个敢声称自己是个软件的东西,基本不会只有一个主窗口吧,大都包含了好多的对话框,分窗口,分窗口里又有好多的对话框。。。这每一个窗口大概都会定义一个自己的类,Class A_Window,Class B_Window。。。类下面会有一堆在那个窗口下你自己设置的控件,比如输入文本框,按钮,复选框之类的。这问题就来了,我在主窗口里的功能设计中,需要使用别的

2021-06-05 21:11:22 1380

原创 cGAN/cDCGAN,MNIST数据集初体验(内含原理,代码)

​生成式对抗网络(Generative Adversarial Networks, GAN),简称GAN网络。有人说这是21世纪最让人激动的“发明”,虽然我忘了我是从哪看到的这句话,貌似是发明了卷积神经网络那位大佬说的。我试过以后,对于AI兴趣爱好者来说确实挺激动的!对于标题中的cGAN/cDCGAN,小c,全称是conditional,条件的。DC,全称是Deep Convolution,深度卷积。都是GAN网络的一个变种。对于DCGAN与GAN的关系,也很简单,因为最开始GAN网络是用神经网络设计的

2021-06-04 21:35:22 2759

原创 RuntimeError: cuDNN error: CUDNN_STATUS_EXECUTION_FAILED解决办法

配置: Python 3.7.6, CUDA 10.0,Pytorch 1.3.1, cudNN 7.6运行时出现如题错误解决办法: 在代码前面添加torch.backends.cudnn.enabled = False作用: 网传是禁用cuDNN作用,官网没有查到相应API说明: 网上查到的靠谱的解决办法,意思大都是说各个版本匹配的问题,个人觉得有一定道理,可能是这么回事,以上办法,也只是针对个人的环境下,可以解决ps:1、什么是CUDACUDA(ComputeUnified Device

2020-09-27 12:24:55 1582 1

原创 使用Python实现DICOM格式批量转换为JPG格式

声明:关于题目所述的解决办法,百度一搜,无论各种博客也好,还是一些别的什么网站给出的办法,无外乎那几种代码形式,也不知道最初的那段代码出自于谁之手,反正就是搬来搬去,抄来抄去,而且有几种版本基本不能用,本人亲测过,而且有些一看,乱七八槽,根本就是复制粘贴过来的,连排版都没有改,无所谓,就是这个环境本篇文章所列方法,也是来源于以上搜索到的一种版本,本人稍作修改,可以用了,并且成功转换,在此向最开始奉献那段代码的博主表示感谢,现在根本分不清最初是出自于谁之手其实解决题目所述问题,无非解决2件事第一个:将

2020-08-06 23:25:09 2676 12

原创 LeetCode算法题之784. Letter Case Permutation(easy)【Python3题解】

题目描述:Given a string S, we can transform every letter individually to be lowercase or uppercase to create another string. Return a list of all possible strings we could create.Examples:Input: S = “a1b2”Output: [“a1b2”, “a1B2”, “A1b2”, “A1B2”]Input: S

2020-06-15 22:01:42 192

原创 LeetCode算法题之221. Maximal Square(Medium)【Python3动态规划题解】

题目描述:Given a 2D binary matrix filled with 0’s and 1’s, find the largest square containing only 1’s and return its area.Example:Input:1 0 1 0 01 0 1 1 11 1 1 1 11 0 0 1 0Output: 4题目大意:给定你一个二维的列表,列表中的每个元素都是0,1字符串让你找出只包含字符1的正方形,且其面积最大,输出其面积值解题思路

2020-06-04 21:40:16 183

原创 Leetcode算法题之152. Maximum Product Subarray(Medium)【Python3题解】

题目描述:Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product.Example 1:Input: [2,3,-2,4]Output: 6Explanation: [2,3] has the largest product 6.Example 2:Input: [-2,0,-1]

2020-05-28 23:08:38 163

原创 LeetCode算法题之139. Word Break(Medium)【Python3题解】

题目描述:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.Note:The same word in the dictionary may be reused multiple t

2020-05-24 23:07:20 215

原创 LeetCode算法题之120. Triangle(Medium)【Python3题解】

题目描述:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangleThe minimum path sum from top to bottom is 11 (i.e., 2 + 3 + 5 + 1 = 11).Note:Bo

2020-05-20 23:10:50 179

原创 LeetCode算法题之63. Unique Paths II(Medium)【Python3题解】

题目描述:A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked ‘Finish’ in t

2020-05-17 22:13:03 199

原创 LeetCode算法题之64. Minimum Path Sum(Medium)【Python3题解】

题目描述:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only move either down or right at any point in time.Example:Input:[[1,3,1],[1,5,1

2020-05-15 23:15:24 190

原创 LeetCode算法题之746. Min Cost Climbing Stairs(easy)【Python3题解】

题目描述:On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach the top of the floor, and you can either start from the step w

2020-05-13 22:35:21 180

原创 手动初始化w,b参数,实现3层神经网络前向传播过程【基于TensorFlow2.0】

先说要干嘛如标题所示,本人是手动定义了神经网络的每一层的w和b,就是采用TF的随机正态分布初始化的数值,然后实现Mnist数据集与w,b参数之间的运算过程,以帮助自己加深印象理解神经网络开始了Step1:加载所需要的包"""导入所需的包,其中包括 TF的高层接口keras里面的数据集接口datasets"""import tensorflow as tffrom tensorflow.keras import datasetsimport os # 因为本人用的TF是2.0-cpu版本,总

2020-05-12 13:09:18 498

原创 LeetCode算法题之392. Is Subsequence(easy)【Python3题解】

题目描述:Given a string s and a string t, check if s is subsequence of t.You may assume that there is only lower case English letters in both s and t. t is potentially a very long (length ~= 500,000) string, and s is a short string (<=100).A subsequence

2020-05-10 22:24:38 150

原创 LeetCode算法题之55. Jump Game(medium)【Python3题解】

题目描述:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you are able to reach the last index.Example 1:Input

2020-05-09 21:39:43 198

原创 那些经典排序算法复现【Python】

1.选择排序算法简介:在给定数组中,找到那个最小的数,与第一个元素交换位置,如果第一个元素就是最小的,那就和本身交换,然后在交换后的数组中,继续寻找最小的,和第二个元素交换,以此类推,每次都选择那个最小的数,故曰,选择排序上代码:class Selection: def sort(self, nums): # 外层循环,指定内层循环找到的最小值要交换到的位置 ...

2020-05-06 20:50:15 176

原创 LeetCode算法题之62. Unique Paths(medium)【Python3题解】

题目描述:A robot is located at the top-left corner of a m x n grid (marked ‘Start’ in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach t...

2020-05-05 22:51:45 214

原创 LeetCode算法题之213. House Robber II(medium)【Python3题解】

题目描述:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed. All houses at this place are arranged in a circle. That means the first hou...

2020-04-29 22:35:01 224

原创 LeetCode算法题之198. House Robber(easy)【Python3动态规划题解】

题目描述:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them is that adjacent...

2020-04-28 23:39:46 230 1

原创 LeetCode算法题之41. First Missing Positive(hard)【Python3题解】

题目描述:Given an unsorted integer array, find the smallest missing positive integer.Example 1:Input: [1,2,0]Output: 3Example 2:Input: [3,4,-1,1]Output: 2Example 3:Input: [7,8,9,11,12]Output: 1...

2020-04-26 21:19:27 149

原创 LeetCode算法题之66. Plus One(easy)【Python3题解】

题目描述:Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each el...

2020-04-25 22:41:21 156

原创 LeetCode算法题之35. Search Insert Position(easy)【Python3题解】

题目描述:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the arr...

2020-04-24 22:37:27 124

原创 LeetCode算法题之309. Best Time to Buy and Sell Stock with Cooldown(medium)【Python3题解】

题目描述:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy...

2020-04-23 12:50:20 183

原创 LeetCode算法题之122. Best Time to Buy and Sell Stock II(easy)【Python3题解】

题目描述:Say you have an array prices for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (...

2020-04-22 22:11:58 229

原创 LeetCode算法题之121. Best Time to Buy and Sell Stock(easy)【Python3动态规划题解】

题目描述:Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (i.e., buy one and sell one share of the st...

2020-04-22 11:18:51 251

原创 LeetCode算法题之70. Climbing Stairs(easy)【Python3递归+动态规划题解】

题目描述:You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a posi...

2020-04-20 21:17:02 180

原创 LeetCode算法题之53. Maximum Subarray(easy)【Python3动态规划题解】

先说大感谢:此篇文章的成型,要特别感谢一个人,labuladong,东哥,算法界一哥,扛把子,得益于他的指点在此也推荐他的公众号,以及他的GitHub仓库,现在已经很火了,公众号:labuladong,GitHub:手把手教你扒LeetCode的裤子,因为很火爆,也很实用,大家应该能找得到,希望看到并感兴趣的朋友,也去学一学好了,开始了题目描述:Given an integer ...

2020-04-20 11:33:34 201

原创 LeetCode算法题之16. 3Sum Closest(medium)【Python3题解】

题目描述:Given an array nums of n integers and an integer target, find three integers in nums such that the sum is closest to target. Return the sum of the three integers. You may assume that each input ...

2020-04-17 10:24:24 170

原创 梯度下降(Gradient Descent)法自动求解一元线性回归中的w,b参数

Step 1:定义损失函数(Loss Function):def loss(w, b, point): total_error = 0#初始化误差值 # 遍历每一个点,将每一个点的误差计算,并加和,且除以N(点的数量) for i in range(len(point)): x = point[i][0] y = point[i][1]...

2020-04-15 22:32:27 1190

原创 LeetCode算法题之28. Implement strStr()(easy)【Python3题解】

题目描述:Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = “hello”, needle = “ll”Output: 2Example...

2020-04-15 12:15:33 125

原创 LeetCode算法题之32. Longest Valid Parentheses(hard)【Python3题解】

题目描述:Given a string containing just the characters ‘(’ and ‘)’, find the length of the longest valid (well-formed) parentheses substring.Example 1:Input: “(()”Output: 2Explanation: The longest va...

2020-04-14 21:20:10 147

原创 LeetCode算法题之10. Regular Expression Matching(hard)【Python3递归法个人详解】

先聊一聊背景如题目所述,这道LeetCode经典算法题,中文名称是正则表达式匹配,如果你已经是刷题的高手,或者还是刚刚刷题的新手,比如我。那么你一定在LeetCode遇到过这道题。那么对于我这个刚刚上路的新手来说,因为这道题的排序是第十位,而我刷题是按照顺序来的,所以很快就遇到了它,结果就是跳过了。。。当时也在网上找过一些答案,基本两种解法最流行吗,其一,是递归;也就是本文将要解释的。其二,...

2020-04-13 12:17:07 209

原创 LeetCode算法题之47. Permutations II(medium)【Python3题解】

题目描述:Given a collection of numbers that might contain duplicates, return all possible unique permutations.Example:Input: [1,1,2]Output:[[1,1,2],[1,2,1],[2,1,1]]题目大意:给定一个数组,但是包含重复的数字,返回所有的不...

2020-04-12 11:02:22 149

原创 LeetCode算法题之46. Permutations(medium)【Python3题解】

题目描述:Given a collection of distinct integers, return all possible permutations.Example:Input: [1,2,3]Output:[[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]题目大意:如题目所示,意为排列,置换,也就是将给定的数组...

2020-04-12 10:24:35 165

原创 LeetCode算法题之40. Combination Sum II(medium)

题目描述:Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.Each number in candidate...

2020-04-10 12:01:16 126

原创 LeetCode算法题之39. Combination Sum(medium)

题目描述:Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target.The same r...

2020-04-09 19:50:19 165

原创 LeetCode算法题之22. Generate Parentheses(medium)

题目描述:Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[“((()))”,“(()())”,“(())()”,“()(())”,“()...

2020-04-06 11:21:08 143

空空如也

空空如也

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

TA关注的人

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