我正在尝试在我的Mac上安装Torch7,但此时安装暂停:
Not updating your shell profile.
You might want to
add the following lines to your shell profile:
export PATH=/Users/khsiddiqui/torch/install/bin:$PATH
export LD_LIBRARY_PATH=/Users/khsiddiqui/torch/install/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=/Users/khsiddiqui/torch/install/lib:$DYLD_LIBRARY_PATH
Run Code Online (Sandbox Code Playgroud)
不确定这意味着什么.上面我收到了以下输出
echo "Error: could not find ipython in PATH. Do you have it installed?"
fi
Run Code Online (Sandbox Code Playgroud)
但是我安装了iPython,因为我可以确认:
No update necessary, 'ipython' is up-to-date.
ipython-3.0.0-3.egg was installed on: Thu Apr 9 18:12:32 2015
kamransiquisMBP:torch khsiddiqui$ env | grep PATH
PATH=/Users/khsiddiqui/Library/Enthought/Canopy_64bit/User/bin:
/usr/local/bin:
/usr/bin:
/bin:
/usr/sbin:
/sbin:
/opt/X11/bin:
/usr/texbin
Run Code Online (Sandbox Code Playgroud)
试图找到.bashrc文件
%edit .bashrc
WARNING: Argument given (.bashrc) can't be found as …Run Code Online (Sandbox Code Playgroud) 我创建了从1到3的数字排列.
th> y = torch.randperm(3 );
th> y
3
2
1
[torch.DoubleTensor of size 3]
Run Code Online (Sandbox Code Playgroud)
现在,我想转换y为Torch.LongTensor.我怎样才能做到这一点?
我从这里读到了卷积神经网络.然后我开始玩火炬7.我对CNN的卷积层感到困惑.
从教程中,
The neurons in a layer will only be connected to a small region of the layer before it, instead of all of the neurons in a fully-connected manner.
For example, suppose that the input volume has size [32x32x3], (e.g. an RGB CIFAR-10 image). If the receptive field is of size 5x5, then each neuron in the Conv Layer will have weights to a [5x5x3] region in the input volume, for a total of 5*5*3 …
machine-learning computer-vision neural-network torch conv-neural-network
我正在寻找一种优雅的方法来选择满足某些约束条件的火炬张量子集.例如,说我有:
A = torch.rand(10,2)-1
Run Code Online (Sandbox Code Playgroud)
并且S是10x1张量,
sel = torch.ge(S,5) -- this is a ByteTensor
Run Code Online (Sandbox Code Playgroud)
我希望能够进行逻辑索引,如下所示:
A1 = A[sel]
Run Code Online (Sandbox Code Playgroud)
但这不起作用.所以有index接受a 的函数LongTensor但我找不到一种简单的方法来转换S为a LongTensor,除了以下内容:
sel = torch.nonzero(sel)
Run Code Online (Sandbox Code Playgroud)
返回K×2张量(K是S> = 5的值的数量).那么我必须将它转换为1维数组,最后允许我索引A:
A:index(1,torch.squeeze(sel:select(2,1)))
Run Code Online (Sandbox Code Playgroud)
这非常麻烦; 在例如Matlab中我所要做的就是
A(S>=5,:)
Run Code Online (Sandbox Code Playgroud)
有谁能建议更好的方法?
我正在尝试从Github fb-caffe- exts 为Torch安装fb-caffe-exts扩展,特别是我正在尝试使用torch2caffe.
我正在尝试为torch2caffe运行test.lua演示,但是我收到以下错误,它指的是test.lua文件中的一行:
t2c.run(opts, module) --attempt to call field 'run' (a nil value)
Run Code Online (Sandbox Code Playgroud)
所有测试都失败,堆栈跟踪引用此错误.我已经安装了依赖项(fb.lualib等)并将lua包添加到我的路径中.导入Fb.python和其他依赖项而不会产生错误.
任何帮助赞赏.
我正在使用Torch7库来实现神经网络.大多数情况下,我依靠预先训练的模型.在Lua中,我使用torch.load函数加载保存为torch .t7文件的模型.我很好奇切换到PyTorch(http://pytorch.org)并阅读了文档.我找不到任何关于加载预训练模型的机制的信息.我能找到的唯一相关信息是此页面:http://pytorch.org/docs/torch.html
但是页面中描述的函数torch.load似乎加载了一个用pickle保存的文件.如果有人在PyTorch中有关于加载.t7模型的其他信息,请在此处分享.
感谢StackOverflow社区的帮助,我能够在运行Linux CentOS 7的计算机上正确安装luasql .
现在我在Linux Ubuntu 16上遇到了类似的问题.我尝试了以下命令:
sudo apt-get -y install lua-sql-postgres
sudo apt-get -y install lua-sql-postgres-dev
sudo luarocks install luasql-postgres
Run Code Online (Sandbox Code Playgroud)
这是我从系统得到的错误:
Installing https://rocks.moonscript.org/luasql-postgres-2.3.5-2.rockspec...
Using https://rocks.moonscript.org/luasql-postgres-2.3.5-2.rockspec... switching to 'build' mode
Error: Could not find expected file libpq-fe.h, or libpq-fe.h for PGSQL -- you may have to install PGSQL in your system and/or pass PGSQL_DIR or PGSQL_INCDIR to the luarocks command. Example: luarocks install luasql-postgres PGSQL_DIR=/usr/local
Run Code Online (Sandbox Code Playgroud)
有谁知道如何解决这个问题?谢谢
假设我从torchvision.datasets.MNIST加载MNIST,但我只想加载10000个图像,我如何切片数据以将其限制为只有一些数据点?我知道DataLoader是一个生成器,产生的数据大小与指定的批量大小相同,但是如何对数据集进行切片?
tr = datasets.MNIST('../data', train=True, download=True, transform=transform)
te = datasets.MNIST('../data', train=False, transform=transform)
train_loader = DataLoader(tr, batch_size=args.batch_size, shuffle=True, num_workers=4, **kwargs)
test_loader = DataLoader(te, batch_size=args.batch_size, shuffle=True, num_workers=4, **kwargs)
Run Code Online (Sandbox Code Playgroud) 也许有人能够在这里帮助我.我正在尝试计算网络给定输出的交叉熵损失
print output
Variable containing:
1.00000e-02 *
-2.2739 2.9964 -7.8353 7.4667 4.6921 0.1391 0.6118 5.2227 6.2540
-7.3584
[torch.FloatTensor of size 1x10]
Run Code Online (Sandbox Code Playgroud)
和所需的标签,形式
print lab
Variable containing:
x
[torch.FloatTensor of size 1]
Run Code Online (Sandbox Code Playgroud)
其中x是0到9之间的整数.根据pytorch文档(http://pytorch.org/docs/master/nn.html)
criterion = nn.CrossEntropyLoss()
loss = criterion(output, lab)
Run Code Online (Sandbox Code Playgroud)
这应该工作,但不幸的是我得到一个奇怪的错误
TypeError: FloatClassNLLCriterion_updateOutput received an invalid combination of arguments - got (int, torch.FloatTensor, !torch.FloatTensor!, torch.FloatTensor, bool, NoneType, torch.FloatTensor, int), but expected (int state, torch.FloatTensor input, torch.LongTensor target, torch.FloatTensor output, bool sizeAverage, [torch.FloatTensor weights or None], torch.FloatTensor total_weight, int ignore_index) …Run Code Online (Sandbox Code Playgroud) 我正在研究PyTorch的基本教程,并遇到了NumPy数组和Torch张量之间的转换。该文件说:
Torch Tensor和NumPy数组将共享其基础内存位置,并且更改一个将更改另一个。
但是,以下代码似乎并非如此:
import numpy as np
a = np.ones((3,3))
b = torch.from_numpy(a)
np.add(a,1,out=a)
print(a)
print(b)
Run Code Online (Sandbox Code Playgroud)
在上述情况下,我看到更改自动反映在输出中:
[[2. 2. 2.]
[2. 2. 2.]
[2. 2. 2.]]
tensor([[2., 2., 2.],
[2., 2., 2.],
[2., 2., 2.]], dtype=torch.float64)
Run Code Online (Sandbox Code Playgroud)
但是当我写这样的东西时,不会发生同样的事情:
a = np.ones((3,3))
b = torch.from_numpy(a)
a = a + 1
print(a)
print(b)
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
[[2. 2. 2.]
[2. 2. 2.]
[2. 2. 2.]]
tensor([[1., 1., 1.],
[1., 1., 1.],
[1., 1., 1.]], dtype=torch.float64)
Run Code Online (Sandbox Code Playgroud)
我在这里想念什么?