lyhue1991 / eat_pytorch_in_20_days Goto Github PK
View Code? Open in Web Editor NEWPytorch🍊🍉 is delicious, just eat it! 😋😋
License: Apache License 2.0
Pytorch🍊🍉 is delicious, just eat it! 😋😋
License: Apache License 2.0
1-2图片建模的执行到features,labels = next(iter(dl_train))时报错_pickle.PicklingError: Can't pickle <function at 0x000002735CA54F28>: attribute lookup on main failed。是windows平台的问题吗
6-2, 训练模型的3种方法
四,类风格 torchkeras.LightModel
line 33
acc = pl.metrics.functional.accuracy(preds, y)
报错如下:
AttributeError: module 'pytorch_lightning.metrics' has no attribute 'functional'
我是来学习pytorch的,看代码发现总是存在torchkeras这个库,如果这个库只是为了查看各层参数之类的.可以将其作为插件介绍一番,没必要篇篇文章都加入,感觉有点不太好.本来就是起步学习,真诚希望代码越简洁越好.
Failed to run summary...
Traceback (most recent call last):
File "D:\Program Files\pytorch'\1-2,图片数据建模流程范例.py", line 66, in
torchkeras.summary(net,input_shape= (3,32,32))
File "D:\Program Files\venv\lib\site-packages\torchkeras\summary.py", line 67, in summary
model(*x) if not (kwargs or args) else model(*x, *args, **kwargs)
File "D:\Program Files\venv\lib\site-packages\torch\nn\modules\module.py", line 1151, in _call_impl
hook_result = hook(self, input, result)
File "D:\Program Files\venv\lib\site-packages\torchkeras\summary.py", line 37, in hook
info["out"] = [batch_size] + list(outputs.size())[1:]
AttributeError: 'NoneType' object has no attribute 'size'
不使用summary后面也会出现AttributeError: 'NoneType' object has no attribute 'size'
trainer = pl.Trainer(max_epochs=20,gpus = 0, callbacks=[ckpt_cb])
trainer.fit(model,dl_train,dl_valid)
在运行这部分代码使用pytorch_lightning时总是报以下错误
'tqdm_notebook' object has no attribute 'reset'
你好,可以上传一下代码中的数据集吗?其中的covid-19.csv按照知乎的链接并没有找到对应的数据文件。请教一下!
一,准备数据 本文的数据集取自tushare,获取该数据集的方法参考了以下文章。
《https://zhuanlan.zhihu.com/p/109556102》
这个知乎链接失效了
when I click on the English links it just took me to the Chinese content
import torchtext的时候报错。
dlopen(/Users/Kingsun/opt/anaconda3/envs/py3/lib/python3.7/site-packages/torchtext/_torchtext.so, 2): Symbol not found: __ZNK3c104Type14isSubtypeOfExtERKNSt3__110shared_ptrIS0_EEPNS1_13basic_ostreamIcNS1_11char_traitsIcEEEE
Referenced from: /Users/Kingsun/opt/anaconda3/envs/py3/lib/python3.7/site-packages/torchtext/_torchtext.so
Expected in: /Users/Kingsun/opt/anaconda3/envs/py3/lib/python3.7/site-packages/torch/lib/libtorch_cpu.dylib
in /Users/Kingsun/opt/anaconda3/envs/py3/lib/python3.7/site-packages/torchtext/_torchtext.so
torchtext 的最新版本0.9.0取消了 Field,只有0.8.1有了。
nn.BCELoss输出未经过sigmod激活,nn.BCEWithLogitsLoss输出自动经过sigmod激活。
nn.CrossEntropyLoss 输出自动经过softmax激活
dl_train = DataLoader(TensorDataset(torch.tensor(x_train).float(),torch.tensor(y_train).float()),
shuffle = True, batch_size = 8)
dl_valid = DataLoader(TensorDataset(torch.tensor(x_test).float(),torch.tensor(y_test).float()),
shuffle = False, batch_size = 8)
AssertionError Traceback (most recent call last)
in
----> 1 dl_train = DataLoader(TensorDataset(torch.tensor(x_train).float(),torch.tensor(y_train).float()),
2 shuffle = True, batch_size = 8)
3 dl_valid = DataLoader(TensorDataset(torch.tensor(x_valid).float(),torch.tensor(y_valid).float()),
4 shuffle = False, batch_size = 8)
~\anaconda3\envs\pytorch\lib\site-packages\torch\utils\data\dataset.py in init(self, *tensors)
34
35 def init(self, *tensors):
---> 36 assert all(tensors[0].size(0) == tensor.size(0) for tensor in tensors)
37 self.tensors = tensors
38
AssertionError:
scalar = torch.tensor(True)
print(scalar.size())
print(vector.shape)
scalar = torch.tensor(True)
print(scalar.size())
print(scalar.shape)
dl_train = DataLoader(TensorDataset(torch.tensor(x_train).float(),torch.tensor(y_train).float()),
shuffle = True, batch_size = 8)
dl_val = DataLoader(TensorDataset(torch.tensor(x_test).float(),torch.tensor(y_test).float()),
shuffle = False, batch_size = 8)
TypeError Traceback (most recent call last)
Cell In[9], line 1
----> 1 dl_train = DataLoader(TensorDataset(torch.tensor(x_train).float(),torch.tensor(y_train).float()),
2 shuffle = True, batch_size = 8)
3 dl_val = DataLoader(TensorDataset(torch.tensor(x_test).float(),torch.tensor(y_test).float()),
4 shuffle = False, batch_size = 8)
TypeError: can't convert np.ndarray of type numpy.object_. The only supported types are: float64, float32, float16, complex64, complex128, int64, int32, int16, int8, uint8, and bool.
请问torchkeras这个模块引用时出错,name 'torchkeras' is not defined,
是自己写的吗?在哪里可以找到?谢谢
in1-2 code:
for x,y in dl_trian:
print(x.shape,y.shape)
break
error:_pickle.PicklingError: Can't pickle <function at 0x000002DDC0CBB048>: attribute lookup on main failed.
because the error the whole code can run correctly
ipython-input-5-ad41ec68ba80> in
7 plt.figure(figsize=(8,8))
8 for i in range(9):
----> 9 img,label = ds_train[i]
10 img = img.permute(1,2,0)
11 ax = plt.subplot(3,3,i+1)
E:\anaconda\envs\pytorch\lib\site-packages\torchvision\datasets\folder.py in getitem(self, index)
151 sample = self.loader(path)
152 if self.transform is not None:
--> 153 sample = self.transform(sample)
154 if self.target_transform is not None:
155 target = self.target_transform(target)
E:\anaconda\envs\pytorch\lib\site-packages\torchvision\transforms\transforms.py in call(self, img)
65 def call(self, img):
66 for t in self.transforms:
---> 67 img = t(img)
68 return img
69
TypeError: object() takes no parameters
作者考虑添加使用 torch.distributed 加速多GPU并行训练的内容吗?貌似比nn.DataParallel快很多
class Model(torchkeras.LightModel):
AttributeError: module 'torchkeras' has no attribute 'LightModel'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.