我真的很想在C++中开始使用谷歌新的Tensorflow库.关于如何构建项目的C++ API,网站和文档真的不清楚,我不知道从哪里开始.
通过发现和分享使用tensorflow的C++ API的指南,有经验帮助的人可以提供帮助吗?
我们在这里处理C. 我只是想到了这个想法,想知道是否有可能访问存储函数的内存中的点foo,并将函数的内容复制到内存中的另一个点.具体来说,我正在努力让以下工作:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
void foo(){
printf("Hello World");
}
int main(){
void (*bar)(void) = malloc(sizeof foo);
memcpy(&bar, &foo, sizeof foo);
bar();
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但运行它会导致总线错误:Bus error: 10.我试图将函数的内容复制foo到一个内存空间bar然后执行新创建的函数bar.
除了查看这样的事情是否可能之外,没有其他原因可以揭示C语言的复杂性.我没想到它有什么实际用途.
我正在寻找指导让这个工作,或以其他方式被告知,有理由,为什么这不起作用
编辑查看一些答案并了解读取,写入和可执行内存,我突然意识到可以通过写入可执行内存来在C中动态创建函数.
我所要做的就是用keras训练我的人工智能,我从theano那里得到了这个绝对令人讨厌的错误告诉我'CVM' is not defined.我已将错误跟踪到model.fit(input, output)我的keras模型函数.
我看到了指示我的邮件列表,rm -rf ~/.theano但这不起作用.
我重新安装了theano和keras但错误仍然存在.
我测试了训练一个简单的keras网络作为控制(以消除我的代码导致错误的假设),但这里也存在错误.
from keras.models import Sequential
from keras.layers import *
X = np.arange(10)
y = X*10
model = Sequential()
model.add(Dense(1, input_shape=(1,)))
model.compile('sgd', 'mean_squared_error')
# Everything is OK up until here
# when I run
model.fit(X,y)
Run Code Online (Sandbox Code Playgroud)
这是我的完整错误跟踪和错误尾部的要点(来自上面的代码片段):
<home>/.conda/envs/flytrackerML/lib/python2.7/site-packages/theano/gof/vm.pyc in make_vm(self, nodes, thunks, input_storage, output_storage, storage_map, post_thunk_clear, computed, compute_map, updated_vars)
911
912 c0 = sys.getrefcount(node_n_inputs)
--> 913 vm …Run Code Online (Sandbox Code Playgroud)