You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
直接跑生成的script报错
indi-gen00-no00.py
Files already downloaded and verified
Files already downloaded and verified
/home/nature/anaconda3/envs/nas/lib/python3.8/site-packages/torch/nn/functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at /pytorch/c10/core/TensorImpl.h:1156.)
return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)
Exception occurs, file:indi-gen00-no00, pid:18314...invalid index of a 0-dim tensor. Use tensor.item() in Python or tensor.item<T>() in C++ to convert a 0-dim tensor to a number
以下是indi-gen00-no00.py文件内部内容:
"""
2022-04-13 19:46:58
"""
from future import print_function
import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import torch.backends.cudnn as cudnn
import torch.optim as optim
import data_loader
import os
from datetime import datetime
import multiprocessing
from utils import StatusUpdateTool
class ResNetBottleneck(nn.Module):
expansion = 1
def __init__(self, in_planes, planes, stride=1):
super(ResNetBottleneck, self).__init__()
self.conv1 = nn.Conv2d(in_planes, planes, kernel_size=1, bias=False)
self.bn1 = nn.BatchNorm2d(planes)
self.conv2 = nn.Conv2d(planes, planes, kernel_size=3, stride=stride, padding=1, bias=False)
self.bn2 = nn.BatchNorm2d(planes)
self.conv3 = nn.Conv2d(planes, self.expansion*planes, kernel_size=1, bias=False)
self.bn3 = nn.BatchNorm2d(self.expansion*planes)
self.shortcut = nn.Sequential()
if stride != 1 or in_planes != self.expansion*planes:
self.shortcut = nn.Sequential(
nn.Conv2d(in_planes, self.expansion*planes, kernel_size=1, stride=stride, bias=False),
nn.BatchNorm2d(self.expansion*planes)
)
def forward(self, x):
out = F.relu(self.bn1(self.conv1(x)))
out = F.relu(self.bn2(self.conv2(out)))
out = self.bn3(self.conv3(out))
out += self.shortcut(x)
out = F.relu(out)
return out
直接跑生成的script报错
indi-gen00-no00.py
Files already downloaded and verified
Files already downloaded and verified
/home/nature/anaconda3/envs/nas/lib/python3.8/site-packages/torch/nn/functional.py:718: UserWarning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (Triggered internally at /pytorch/c10/core/TensorImpl.h:1156.)
return torch.max_pool2d(input, kernel_size, stride, padding, dilation, ceil_mode)
Exception occurs, file:indi-gen00-no00, pid:18314...invalid index of a 0-dim tensor. Use
tensor.item()
in Python ortensor.item<T>()
in C++ to convert a 0-dim tensor to a number以下是indi-gen00-no00.py文件内部内容:
"""
2022-04-13 19:46:58
"""
from future import print_function
import torch
from torch.autograd import Variable
import torch.nn as nn
import torch.nn.functional as F
import torch.backends.cudnn as cudnn
import torch.optim as optim
import data_loader
import os
from datetime import datetime
import multiprocessing
from utils import StatusUpdateTool
class ResNetBottleneck(nn.Module):
expansion = 1
class ResNetUnit(nn.Module):
def init(self, amount, in_channel, out_channel):
super(ResNetUnit, self).init()
self.in_planes = in_channel
self.layer = self._make_layer(ResNetBottleneck, out_channel, amount, stride=1)
class DenseNetBottleneck(nn.Module):
def init(self, nChannels, growthRate):
super(DenseNetBottleneck, self).init()
interChannels = 4*growthRate
self.bn1 = nn.BatchNorm2d(nChannels)
self.conv1 = nn.Conv2d(nChannels, interChannels, kernel_size=1,
bias=False)
self.bn2 = nn.BatchNorm2d(interChannels)
self.conv2 = nn.Conv2d(interChannels, growthRate, kernel_size=3,
padding=1, bias=False)
class DenseNetUnit(nn.Module):
def init(self, k, amount, in_channel, out_channel, max_input_channel):
super(DenseNetUnit, self).init()
self.out_channel = out_channel
if in_channel > max_input_channel:
self.need_conv = True
self.bn = nn.BatchNorm2d(in_channel)
self.conv = nn.Conv2d(in_channel, max_input_channel, kernel_size=1, bias=False)
in_channel = max_input_channel
class EvoCNNModel(nn.Module):
def init(self):
super(EvoCNNModel, self).init()
class TrainModel(object):
def init(self):
trainloader, validate_loader = data_loader.get_train_valid_loader('../data_cifar10', batch_size=128, augment=True, valid_size=0.1, shuffle=True, random_seed=2312390, show_sample=False, num_workers=1, pin_memory=True)
#testloader = data_loader.get_test_loader('../data_cifar10', batch_size=128, shuffle=False, num_workers=1, pin_memory=True)
net = EvoCNNModel()
cudnn.benchmark = True
net = net.cuda()
criterion = nn.CrossEntropyLoss()
best_acc = 0.0
self.net = net
self.criterion = criterion
self.best_acc = best_acc
self.trainloader = trainloader
self.validate_loader = validate_loader
self.file_id = os.path.basename(file).split('.')[0]
#self.testloader = testloader
#self.log_record(net, first_time=True)
#self.log_record('+'*50, first_time=False)
class RunModel(object):
@classmethod
def do_work(self, gpu_id, file_id):
os.environ['CUDA_VISIBLE_DEVICES'] = gpu_id
best_acc = 0.0
try:
m = TrainModel()
m.log_record('Used GPU#%s, worker name:%s[%d]'%(gpu_id, multiprocessing.current_process().name, os.getpid()), first_time=True)
best_acc = m.process()
#import random
#best_acc = random.random()
except BaseException as e:
print('Exception occurs, file:%s, pid:%d...%s'%(file_id, os.getpid(), str(e)))
m.log_record('Exception occur:%s'%(str(e)))
finally:
m.log_record('Finished-Acc:%.3f'%best_acc)
if name == 'main':
RunModel.do_work(gpu_id='0', file_id='indi-gen00-no00')
The text was updated successfully, but these errors were encountered: