我在神经网络的最后一层使用Softmax激活函数.但我在安全实现此功能时遇到问题.
一个天真的实现将是这个:
Vector y = mlp(x); // output of the neural network without softmax activation function
for(int f = 0; f < y.rows(); f++)
y(f) = exp(y(f));
y /= y.sum();
Run Code Online (Sandbox Code Playgroud)
对于> 100个隐藏节点,这不能很好地工作,因为y NaN在很多情况下(如果y(f)> 709,exp(y(f))将返回inf).我想出了这个版本:
Vector y = mlp(x); // output of the neural network without softmax activation function
for(int f = 0; f < y.rows(); f++)
y(f) = safeExp(y(f), y.rows());
y /= y.sum();
Run Code Online (Sandbox Code Playgroud)
在哪里safeExp定义为
double safeExp(double x, int div)
{
static const double maxX = …Run Code Online (Sandbox Code Playgroud) 我正在尝试启动Octopus Arm Benchmark(强化学习基准).我下载了octopus-code-distribution.zip并启动了octopus-environment.jar
java -jar octopus-environment.jar internal settings.xml
Run Code Online (Sandbox Code Playgroud)
我得到以下例外:
Exception in thread "main" java.lang.NoSuchMethodError: javax.xml.bind.annotation.XmlAccessorType.value()Ljavax/xml/bind/annotation/AccessType;
at com.sun.xml.bind.v2.model.impl.ClassInfoImpl.getAccessType(ClassInfoImpl.java:339)
at com.sun.xml.bind.v2.model.impl.ClassInfoImpl.getProperties(ClassInfoImpl.java:228)
at com.sun.xml.bind.v2.model.impl.RuntimeClassInfoImpl.getProperties(RuntimeClassInfoImpl.java:87)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getClassInfo(ModelBuilder.java:127)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:49)
at com.sun.xml.bind.v2.model.impl.RuntimeModelBuilder.getClassInfo(RuntimeModelBuilder.java:41)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:189)
at com.sun.xml.bind.v2.model.impl.ModelBuilder.getTypeInfo(ModelBuilder.java:204)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:327)
at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:198)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:76)
at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:202)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:363)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:574)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:522)
at Main.main(Main.java:41)
Run Code Online (Sandbox Code Playgroud)
我已经用Google搜索了错误消息,这似乎是我的Java版本的一个问题.我正在使用Java 1.6,它以某种方式导致与JAXB库的冲突.我认为它适用于Java 1.5.但我还没有找到任何解决方法.
我希望你能在这里帮助我.一些背景信息:我使用的是Ubuntu 11.04,我的Java版本是1.6.0_26.
我今天开始了一个小实验:我编写了一个C++类,它取决于其他一些库(ALGLIB,Eigen,内部工具),我想为该类创建一个Ruby包装器.我目前正在使用Rice这样做.首先,我为我的类编写了一个非常简单的C++包装器:
// @file MLPWrapper.h
#pragma once
#include "mlp/MLP.h"
#include <ruby.h>
class MLPWrapper
{
MLP mlp; // <- my C++ class
public:
...
void fit()
{
...
mlp.fit(stop);
}
};
Run Code Online (Sandbox Code Playgroud)
库的cpp文件是这样的:
// @file cmlp.cpp
#include "rice/Data_Type.hpp"
#include "rice/Constructor.hpp"
#include "MLPWrapper.h"
using namespace Rice;
extern "C"
void Init_cmlp()
{
Data_Type<MLPWrapper> rb_cMLPWrapper = define_class<MLPWrapper>("MLP")
.define_constructor(Constructor<MLPWrapper>())
...
.define_method("fit", &MLPWrapper::fit);
}
Run Code Online (Sandbox Code Playgroud)
这是extconf.rb:
require "mkmf-rice"
$CFLAGS << "-O3"
HEADER_DIRS = [
"..",
"../../external/libraries/eigen-eigen-3.0.1",
"../../external/libraries/alglib/cpp/src",
"../../external/libraries/CMA-ESpp"
]
LIB_DIRS = [
"../../build/external/libraries/alglib/cpp/src",
"../../build/external/libraries/CMA-ESpp/cma-es",
"../../build/src/tools"
]
dir_config("libs", …Run Code Online (Sandbox Code Playgroud) 假设我有一堂课
class A(object):
def myfunction():
"""A."""
pass
Run Code Online (Sandbox Code Playgroud)
和一个子类
class B(A):
def myfunction():
pass
Run Code Online (Sandbox Code Playgroud)
是否可以使用sphinx从A.myfunction继承B.myfunction的API文档?B.myfunction的文档应为"A".同样.