1.pytorch报错:ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1,512,1,1])

2.网上查找的原因为模型中用了batchnomolization,训练中用batch训练的时候当前batch恰好只含一个sample,而由于BatchNorm操作需要多于一个数据计算平均值,因此造成该错误。

3.解决方法:在torch.utils.data.DataLoader类中或自己创建的继承于DataLoader的类中设置参数drop_last=True,把不够一个batch_size的数据丢弃。

成功解决。

pytorch报错:ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1,512,1,1])的更多相关文章

  1. [已解决]报错:ValueError: Expected 2D array, got scalar array instead

    报错代码: new_x = 84610 pre_y = model.predict(new_x) print(pre_y) 报错结果: ValueError: Expected 2D array, g ...

  2. pytorch中使用多显卡训练以及训练时报错:expect more than 1 value per channel when training, got input size..

    pytorch在训练中使用多卡: conf.device = torch.device('cuda:0' if torch.cuda.is_available() else "cpu&quo ...

  3. 读取导入csv csv报错iterable expected, not float

    示例代码import pandas as pdimport reimport csv data = pd.read_csv('nuojia.csv', encoding='utf-8')# print ...

  4. keras 报错 ValueError: Tensor conversion requested dtype int32 for Tensor with dtype float32: 'Tensor("embedding_1/random_uniform:0", shape=(5001, 128), dtype=float32)'

    在服务器上训练并保存模型,复制到本地之后load_model()报错: ValueError: Tensor conversion requested dtype int32 for Tensor w ...

  5. selenium调用Firefox和Chrome需要注意的一些问题,和出现的报错selenium:expected [object undefined] undefined to be a string

    在高版本selenium下如:selenium3.4.3 1.高版本的selenium需要浏览器安装一些补丁驱动 Firefox:geckodriver 下载网址:http://download.cs ...

  6. matplotlib.pyplot import报错: ValueError: _getfullpathname: embedded null character in path

    Environment: Windows 10, Anaconda 3.6 matplotlib 2.0 import matplotlib.pyplot 报错: ValueError: _getfu ...

  7. dbfread报错ValueError错误解决方法

    问题 我在用dbfread处理.dbf数据的时候出现了报错 ValueError("could not convert string to float: b'.'",) 然后查找. ...

  8. Pytorch报错:cuda runtime error (59) : device-side assert triggered at /pytorch/aten/src/THC/generic/THCTensorMath.cu:26

    Pytorch报错:cuda runtime error (59) : device-side assert triggered at /pytorch/aten/src/THC/generic/TH ...

  9. 前端控制台 JavaScript函数报错 SyntaxError: expected expression, got ';' SyntaxError: expected expression, got 'if'

    在火狐浏览器下调试时, 页面报错SyntaxError: expected expression, got ';'或者SyntaxError: expected expression, got 'if ...

随机推荐

  1. Fishing Master (思维+贪心)

    题目网站:http://acm.hdu.edu.cn/showproblem.php?pid=6709 Problem Description Heard that eom is a fishing ...

  2. Codeforces Global Round 2 D 差分 + 前缀和 + 二分

    https://codeforces.com/contest/1119/problem/D 题意 有n个数组,每个数组大小为\(10^{18}+1\)且为等差数列,给出n个数组的\(s[i]\),q次 ...

  3. B1042 字符统计 (20 分)

    #include<cstdio> #include<iostream> #include<algorithm> #include<string> usi ...

  4. [LeetCode] 419. Battleships in a Board 平板上的战船

    Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, ...

  5. JavaScript 系列--JavaScript一些奇淫技巧的实现方法(三)数字取整,数组求和

    一.前言 简短的sleep函数,获取时间戳:https://www.mwcxs.top/page/746.html 数字格式化 1234567890 --> 1,234,567,890:argr ...

  6. HTTP之Web服务器是如何进行工作的!

    Web服务器是如何进行工作的 ====================文章摘自<HTTP权威指南>====================== 1.  建立连接—接收一个客户端的连接,或者 ...

  7. 初识Go语言--(2)Hello World

    新建hello.go文件,内容如下 package main import "fmt" func main() { //输出Hello World fmt.Println(&quo ...

  8. springboot打war包汇总

    概述 第一次用maven工具打war包,出现各种各样的问题,做个问题记录方便下次查看 maven 一开始用的maven是springboot默认的,在.m2下,要打包时才发现没有mvn指令.索性自己就 ...

  9. Linux 笔记 - 第二十二章 Nginx 配置 SSL

    一.前言 基础知识 1.1 公钥密码体制(public-key cryptography) 公钥密码体制分为三个部分,公钥.私钥.加密解密算法,它的加密解密过程如下: 加密:通过加密算法和公钥对内容( ...

  10. 2019-11-29-WPF-非客户区的触摸和鼠标点击响应

    原文:2019-11-29-WPF-非客户区的触摸和鼠标点击响应 title author date CreateTime categories WPF 非客户区的触摸和鼠标点击响应 lindexi ...