小编Ada*_*han的帖子

NameError:未定义名称"get_ipython"

我正在使用Caffe框架并使用PyCaffe接口.我正在使用从转换IPython Notebook 00-classification.ipynb获得的Python脚本,用于通过ImageNet的训练模型测试分类.但是脚本中的任何get_ipython()语句都会出现以下错误:

$ python python/my_test_imagenet.py 
Traceback (most recent call last):
  File "python/my_test_imagenet.py", line 23, in <module>
    get_ipython().magic(u'matplotlib inline')
Run Code Online (Sandbox Code Playgroud)

在脚本中,我正在导入以下内容:

import numpy as np
import matplotlib.pyplot as plt

get_ipython().magic(u'matplotlib inline')

# Make sure that caffe is on the python path:
caffe_root = '/path/to/caffe/'
import sys
sys.path.insert(0, caffe_root + 'python')

import caffe

plt.rcParams['figure.figsize'] = (10, 10)
plt.rcParams['image.interpolation'] = 'nearest'
plt.rcParams['image.cmap'] = 'gray'

import os

# ... Rest of the code...
Run Code Online (Sandbox Code Playgroud)

有人可以帮我解决这个错误吗?

python ipython caffe pycaffe

31
推荐指数
3
解决办法
5万
查看次数

C++ STL 按值设置擦除

我想从std::set.

我知道最好和直接的做法是使用set<T>::find(T val)方法检查它在集合中的存在,然后使用返回的set<T>::iterator. 但我希望使用按值擦除的速记方法。

尽管std::set确实通过重载函数提供了set<T>::erase(T val)此处列出的值擦除的功能,但我无法找到如果该值不存在于集合中会发生什么。

正如人们直觉所期望的那样,如果参数值在集合中不存在,它是否什么都不做?是否保证它不会抛出任何错误/异常?

c++ stl set

7
推荐指数
2
解决办法
2099
查看次数

从一维张量中提取前k个值索引

给定Torch中的一维张量(torch.Tensor),其中包含可以比较的值(例如浮点数),我们如何提取该张量中前k个值的索引?

除了蛮力方法外,我还在寻找Torch / lua提供的一些API调用,它可以有效地执行此任务。

lua torch

4
推荐指数
2
解决办法
3022
查看次数

Bash脚本删除给定目录中的所有图像文件

我使用以下shell脚本来清​​除我正在运行的python脚本的后果:

echo "Cleaning up..."
# some other files removed here...
# removing some log files
if [ -f log_errors.txt ]; then
    rm log_errors.txt
fi
# removing all the generated image files
if [ -f IMG_* ]; then
    rm IMG_*
fi
# some more files removed here...
ls
Run Code Online (Sandbox Code Playgroud)

但是,在做的时候bash clean.sh,我收到以下错误:

Cleaning up...
clean.sh: line 11: [: too many arguments
Run Code Online (Sandbox Code Playgroud)

有人可以帮帮我吗?提前致谢.

编辑:请考虑此目录中没有子文件夹.

bash shell

1
推荐指数
1
解决办法
773
查看次数

标签 统计

bash ×1

c++ ×1

caffe ×1

ipython ×1

lua ×1

pycaffe ×1

python ×1

set ×1

shell ×1

stl ×1

torch ×1