我正在尝试实现这个合并层:
policy = merge([out1, out2], mode = lambda x: x[0]-K.mean(x[0])+x[1], output_shape = (out_node,))
Run Code Online (Sandbox Code Playgroud)
但是,Keras 2 中不再存在“合并”。您只能访问公共标准化的“合并”层,例如 Add、Multiply、Dot。
如何在 Keras 2 中实现此功能?我想制作两个合并层,但我不知道如何实现,尤其是因为“K.mean”部分。
作为参考,这里是进口:
from keras.layers import merge
from keras import backend as K
Run Code Online (Sandbox Code Playgroud) 当我尝试使用vector.size()时,它给出了以下错误:
In function 'int main()':
[Error] expected unqualified-id before '(' token
[Error] expected primary-expression before ')' token
[Error] lambda-expression in unevaluated context
[Error] expected identifier before numeric constant
In lambda function:
[Error] expected '{' before ')' token
Run Code Online (Sandbox Code Playgroud)
其余的向量函数都有效.我之前使用过这个功能而且它有效,现在我无法使用它.
这是代码:
while(1)
{
vector<string> frase;
string stringa;
getline(cin,stringa);
{
string temp;
temp.clear();
for(int i=0;i<stringa.length();i++)
{
if(stringa[i]!=' ')temp+=stringa[i];
else
{
frase.push_back(temp);
temp.clear();
}
}
frase.push_back(temp);
}
analizza(frase.data(), /*ERROR HERE*/ frase.size() /*ERROR HERE*/);
frase.clear();
for(int i=0;i<frase.size();i++)frase.pop_back();
}
Run Code Online (Sandbox Code Playgroud)
我能做什么?