我有以下代码:
QStringListModel* m=new QStringListModel(gc.get_lista_file());
ui->lista_immagini_listView->setModel(m);
Run Code Online (Sandbox Code Playgroud)
其中gc.get_lista_file()返回一个QStringList对象和lista_immagini_listView一个QListView.我需要更新我lista_immagini_listView添加一个字符串,当我按下一个按钮,但如果我在我的新字符串添加到我的QStringList对象时不更新我的模型(我读的QStringList是通过复制传递,因此它没有连接到模型) .所以,我必须更新我,QStringListModel但这样我必须更新2对象(QStringList和QStringListModel),似乎不是一个好习惯.解决它的最佳方式(如果存在)是什么?
我想知道怎样loadNibNamed的NSBundle类作品; 在某些文件中我发现了类似的东西
[[NSBundle mainBundle] loadNibNamed:@"mynib" owner:self options:NULL];
Run Code Online (Sandbox Code Playgroud)
没有回报价值; 只是在方法内部调用(例如,cellForRowAtIndexPath如果我想自定义我的单元格).在其他文件中我发现:
NSArray* vett=[[NSBundle mainBundle] loadNibNamed:@"mynib" owner:self options:NULL];
Run Code Online (Sandbox Code Playgroud)
在这种情况下,例如cellForRowAtIndexPath,我可以
return [vett lastObject];
Run Code Online (Sandbox Code Playgroud)
或类似的东西.后一种方法在我看来很清楚; 我在一个向量中加载笔尖然后我使用向量元素.问题是要了解第一个究竟是做什么的:
[[NSBundle mainBundle] loadNibNamed:@"mynib" owner:self options:NULL];
Run Code Online (Sandbox Code Playgroud)
没有返回值,没有单元格引用...我的笔尖的对象在哪里?他们是如何处理的?我不明白它是如何工作的
我正在阅读以下文章作为我的硕士论文:http: //graphics.cs.cmu.edu/projects/discriminativePatches/discriminativePatches.pdf 在2.1节中它说:"我们将判别聚类的分类步骤转变为检测步骤"分类和检测有什么区别?最初我认为这意味着使用"分类器"它将定义更多类的分类器(然后只存在输入=图像补丁,输出=类的所有类的分类器),而"探测器"只有一个分类器class(然后为每个类存在一个不同的检测器,输入=图像补丁,输出=是/否).但在那之前,他说"数据的初始聚类之后是学习一个描述性的分类器FOR FOR CHACH CLUSTER(class)",然后,对于分类器,它意味着"对于每个类(聚类)存在一个分类器".然后..它会说区分分类器和检测?谢谢
classification cluster-analysis machine-learning detection computer-vision
我明白为什么
scene.setCursor(Cursor.WAIT);
long task...
scene.setCursor(Cursor.DEFAULT);
Run Code Online (Sandbox Code Playgroud)
需要新线程; 它适用于:
private void set_cursore_attesa(final Scene scene)
{
Runnable r=new Runnable() {
@Override
public void run() {
scene.setCursor(Cursor.WAIT);
}
};
Thread t=new Thread(r);
t.start();
}
private void set_cursore_normale(final Scene scene)
{
Runnable r=new Runnable() {
@Override
public void run() {
scene.setCursor(Cursor.DEFAULT);
}
};
Thread t=new Thread(r);
t.start();
}
in my function:
set_cursore_attesa(scene);
long task...
set_cursore_normale(scene);
Run Code Online (Sandbox Code Playgroud)
为什么我不能使用相同的线程?一世:
那么,我的长任务不会进入MAIN队列?因为,如果它进入主队列,我预计它会在我首先插入队列的WAIT游标之后执行.为什么会这样?
我不明白Matlab并行计算工具箱中的parfor cicle如何与内存一起工作:我读到它在所有工作人员之间共享内存(然后我认为每个工作人员(核心)都可以访问感兴趣的内存位置而无需制作本地副本)但是其他参考资料告诉我,每个核心都会在其工作的地方创建内存(变量等)的本地副本!答案是什么?Parfor 有共享内存系统并且不制作数据副本或者每个工作人员都有数据的本地副本?谢谢
parallel-processing matlab memory-management shared-memory parfor
struct A{
int V[100];
};
void f(A a)
{
a.V[0]=30;
}
int main()
{
A a;
a.V[0]=10;
f(a);
cout<<a.V[0];
}
Run Code Online (Sandbox Code Playgroud)
我期望30作为输出,而不是我获得10.我知道,如果参数是通过值传递的,数组(也可以是类/结构的成员)通过引用传递.相反,当成员,他们通过副本传递.是真的?
我需要向现有模型添加图层。但是,我需要在“主模型级别”添加层,即我不能使用经典的函数方法。例如,如果我使用类似的东西:
from keras.layers import Dense,Reshape, Input
inp = Input(shape=(15,))
d1 = Dense(224*224*3, activation='linear')(inp)
r1 = Reshape(input_shape)
from keras import Model
model_mod = r1(d1)
model_mod = mobilenet(model_mod)
model_mod = Model(inp, model_mod)
Run Code Online (Sandbox Code Playgroud)
我获得:
Layer (type) Output Shape Param #
=================================================================
input_5 (InputLayer) (None, 15) 0
_________________________________________________________________
dense_4 (Dense) (None, 150528) 2408448
_________________________________________________________________
reshape_4 (Reshape) (None, 224, 224, 3) 0
_________________________________________________________________
mobilenet_1.00_224 (Model) (None, 1000) 4253864
Run Code Online (Sandbox Code Playgroud)
所以,我获得了一个带有嵌套子模型的模型。相反,我会将嵌套子模型的层(mobilenet)“添加”到新的顶层(即在 reshape_4 之后)。我试过:
modelB_input = modelB.input
for layer in modelB.layers:
if layer == modelB_input:
continue
modelA.add(layer)
Run Code Online (Sandbox Code Playgroud)
它适用于简单的顺序模型(例如,vgg、mobilenet),但对于连接不是严格顺序的更复杂的模型(例如,inception、resnet),此代码并不好。有任何想法吗?
我试图了解基本的 pytorch autograd 系统:
x = torch.tensor(10., requires_grad=True)
print('tensor:',x)
x.backward()
print('gradient:',x.grad)
Run Code Online (Sandbox Code Playgroud)
输出:
tensor: tensor(10., requires_grad=True)
gradient: tensor(1.)
Run Code Online (Sandbox Code Playgroud)
由于x是一个标量常量并且没有函数应用于它,所以我期望0.作为梯度输出。为什么是渐变1.呢?
我需要在没有清除命令的情况下使用Matlab释放内存(我在并行工具箱的parfor循环中,无法调用clear);我读的是,例如,
clear v
Run Code Online (Sandbox Code Playgroud)
我可以设定
v=[]
Run Code Online (Sandbox Code Playgroud)
问题是:使用'= []',我会取消分配'v'的内存,或者只是将v设置为空值,并且先前的内存仍在分配,然后无法使用?谢谢
我可以使用单个索引索引多维数组吗?
例如:
在内存中,多维数组被索引为单个数组(例如矩阵2x2,矩阵[1] [1]是数组的第四个元素,"矩阵[3]")是否有系统自动使用此表示法?我想写矩阵[3]而不是矩阵[1] [1]:可能吗?
#include <thread>
#include <iostream>
using namespace std;
class A
{
public:
A(){}
void m(std::string* s)
{
cout<<*s;
}
void m(std::string s)
{
cout<<s;
}
};
int main()
{
A a;
string str="hi!\n";
std::thread(&A::m,a,&str);
}
Run Code Online (Sandbox Code Playgroud)
这不编译; 它给:
error: no matching function for call to ‘std::thread::thread(<unresolved overloaded function type>, A&, std::string*)’
Run Code Online (Sandbox Code Playgroud)
如果我删除第二个成员,它编译!为什么?我不能在std :: thread中使用重载方法?
我想要一个带有前缀的ostream,在cout上重定向的每一行的开头; 我试试这个:
#include <iostream>
#include <thread>
class parallel_cout : public std::ostream
{
public:
parallel_cout(std::ostream& o):out(o){}
template <typename T>
std::ostream& operator<< (const T& val)
{
out << "prefix " << val;
return *this;
}
std::ostream& out;
};
int main()
{
parallel_cout pc(std::cout);
pc<<"a\nb"<<"c\n";
}
Run Code Online (Sandbox Code Playgroud)
但我有输出
prefix a
b
Run Code Online (Sandbox Code Playgroud)
没有c.为什么这个?
我需要为我的类创建一个复制构造函数,Immagine如下所示:
Immagine::Immagine(Immagine& i)
{
...
}
Run Code Online (Sandbox Code Playgroud)
很明显,当我试着打电话时,我有类似的东西:
error: invalid initialization of non-const reference of type ‘Immagine&’ from an rvalue of type ‘Immagine’因为我会声明它:
Immagine::Immagine(const Immagine& i)
{
...
}
Run Code Online (Sandbox Code Playgroud)
但我无法做到这一点,因为,为了对一个Immagine成员对象进行初始化,我使用了一个函数
Immagine::Immagine(const Immagine& i)
{
dlib::array2d<dlib::rgb_pixel>& r=i.v; //v is a member of type dlib::array2d<dlib::rgb_pixel>
dlib::assign_image(this->dlib_immagine,r);
}
Run Code Online (Sandbox Code Playgroud)
功能dlib::assign_image(dst,src)是封装功能,并复制src到dst,但没有被声明const为src参数,所以如果我声明i作为const我得到一个错误......我该如何解决这个问题?
c++ ×6
matlab ×2
parfor ×2
autograd ×1
clear ×1
const ×1
constructor ×1
cout ×1
detection ×1
indexing ×1
ios ×1
iostream ×1
java ×1
javafx ×1
keras ×1
keras-layer ×1
loadnibnamed ×1
matrix ×1
nsbundle ×1
objective-c ×1
ostream ×1
overloading ×1
python ×1
pytorch ×1
qt ×1
shared ×1
std ×1
stdthread ×1
struct ×1
tf.keras ×1
threadpool ×1
torch ×1