草庐IT

enable_dl

全部标签

[ML&DL] 分类问题

分类问题分类问题和回归问题的区别是:分类问题的值域是离散的。线性回归不能应用于分类问题。逻辑回归模型(此处为一元分类问题)预测函数:\[h_\theta(x)=g(\theta^Tx)\]其中:\[g(z)=\frac{1}{1+e^{-z}}\]能够使得:\[0\leh_\theta(x)\le1\]预测函数的函数值:\[y=1\Leftrightarrowh_\theta(x)\ge0.5\Leftrightarrow\theta^Tx\ge0\\y=0\Leftrightarrowh_\theta(x)决策界限\(y=1\\or\\0\)取决于\(h_\theta(x)\ge0.5\\o

c++ - 将成员声明与 enable_if 一起使用?

我需要有条件地使用成员声明。templatestructB;templatestructB{voidfoo();};templatestructB{};templatestructA:publicB::value>{usingB::value>::foo();voidfoo(int){}};这显然行不通,因为B::foo没有定义在一半的情况下。我怎样才能做到这一点?拥有B::foo()在A中可见foo(int)旁边的作用域?感谢帮助 最佳答案 这是我的解决方案。我敢肯定它不会是最好的,但它可以完成工作。structA{voidfoo

c++ - noexcept 运算符和 enable_if_t : do they work together?

考虑以下类:structS{templatestd::enable_if_t::value>f()noexcept{}templatestd::enable_if_t::value>g()noexcept{}};正如预期的那样,编译:s.f();这个不是:s.g();令我困惑的是,下面的main是用GCC(6.2)编译的,而不是用clang(3.9)编译的:intmain(){static_assert(noexcept(&S::f),"!");static_assert(noexcept(&S::g),"!");}我会说第二个断言失败是因为特化无效。两个编译器不同意这一点。哪个是正确

c++ - 使用 enable_if 禁用模板类的模板构造函数

当模板构造函数的参数类型与类型“MyClass匹配时,我试图使用std::enable_if禁用模板类的模板构造函数"这样我就可以使用我的其他构造函数,它允许我用另一个模板的类初始化当前模板的类。templateclassMyClass{public:MyClass(){data.fill(static_cast(0));}template//iwanttodisablethisifArgs=MyClassMyClass(Args&&...args):data{std::forward(args)...}{}templateMyClass(constMyclass&other_size

c++ - 带有 std::enable_if 和 std::is_default_constructible 的 SFINAE 用于 libc++ 中的不完整类型

我刚刚在使用SFINAE检测模板类型是否默认可构造时观察到libc++的一个奇怪问题。以下是我能够想出的一个最小示例:#include#includetemplatestructDummy;templatestructDummy{};templatestructhas_dummy:std::false_type{};templatestructhas_dummy>::value>>:std::true_type{};intmain(){std::cout{}(){}()它编译并输出预期的行true和false使用libstdc++使用g++或clang++编译时.但是,当我尝试使用li

c++ - 为什么 SFINAE (enable_if) 从类定义内部工作而不是从外部工作

过去几个小时我一直在努力解决一个非常奇怪的问题(在用SFINAE解决了5-6个其他问题之后,因为我是新手)。基本上在下面的代码中,我想让f()为所有可能的模板实例化工作,但是g()仅在N==2:#include#includetemplateclassA{public:voidf(void);voidg(void);};templateinlinevoidA::f(){std::cout::type*=nullptr>inlinevoidA::g(){std::coutobj;obj.f();obj.g();return0;}当我尝试编译它时,我收到一个关于有3个而不是两个模板参数的错

c++ - 为什么使用 boost::ice_or 而不是 ||和 boost::ice_and 而不是 enable_if 中的 &&?

如问题所述,人们使用结构版本而不是正常条件是否有原因? 最佳答案 摘自BoostCodingGuidelinesforIntegralConstantExpressions:Don'tuselogicaloperatorsinintegralconstantexpressions;usetemplatemeta-programminginstead.Theheadercontainsanumberofworkaroundtemplates,thatfulfiltheroleoflogicaloperators,forexamplei

c++ - 使用 valgrind 在内存泄漏检测中抑制 "dl-hack3-cond-1"

我正在使用valgrind来检测内存泄漏。valgrind的输出由命令生成valgrind-v--leak-check=full../spythontest.py2>/tmp/log事实上,我的程序是一个高度简化的python解释器(作业ToT),正如您可以从名称spythontest.py推断的那样困扰我的是底部的输出==24269==ERRORSUMMARY:0errorsfrom0contexts(suppressed:3from3)--24269----24269--used_suppression:3dl-hack3-cond-1这是什么意思?我查了一下,在valgrind的

c++ - 模板特化 enable_if

我正在尝试以这种方式专门化模板:classPropertyBase{public:SfPropertyBase(stringname){Name=name;}virtual~SfPropertyBase(){}stringName;virtualboolFromString(Object*obj,stringstr)=0;};templateclassProperty:publicSfPropertyBase{public:Property(stringname):SfPropertyBase(name){//specifictoPropertystuff}templatetypena

c++ - enable_shared_from_this 需要什么?

这个问题在这里已经有了答案:Whatistheusefulnessof`enable_shared_from_this`?(6个答案)关闭6年前。我是C++11的新手,我遇到了enable_shared_from_this。我不明白它试图达到什么目的?所以我有一个使用enable_shared_from_this的程序。structTestCase:enable_shared_from_this{std::shared_ptrgetptr(){returnshared_from_this();}~TestCase(){std::coutobj1(newTestCase);std::sh