• "Ground truth" means a set of measurements that is known to be much more accurate than measurements from the system you are testing. For example, suppose you are testing a stereo vision system to see...

"Ground truth" means a set of measurements that is known to be much more accurate than measurements from the system you are testing.

For example, suppose you are testing a stereo vision system to see how well it can estimate 3D positions. The "ground truth" might be the positions given by a laser rangefinder which is known to be much more accurate than the camera system.

Sometimes synthetic data are generated from a model, to test a system whose goal is to estimate parameters of the model. In such cases the "ground truth" is the known parameters of the model. Again stereo vision provides a good example: computer graphics can generate synthetic images from a 3D model, and then a stereo vision system can try to reconstruct the model. The original model is the "ground truth".

In the case of edge detection, it's much less clear what "ground truth" means, and in fact I don't think it's well defined, as edge detection generally involves making some (more or less) arbitrary choices. Nonetheless, I can think of two possible candidates: one is the output of an edge-detector which is generally accepted to be high-quality; the other is the edges drawn by an expert human looking at the image. Neither of these is really ground truth, however, and the term "gold standard" would be more applicable.

This comes down to a question to you: what is your ultimate goal? That is, why do you want "ground truth"?

展开全文
• So much has changed in three years, in fact, that we were compelled to write another book. The Truth Machine expands the conversation we began in 2015 and takes it to a level higher. It explores how ...
• 参考Drools官方文档(3.1 KIE Session和3.2 Inference and truth maintenance in the Drools engine)，学习关于Kie Session和Truth maintenace的内容。这两节内容虽然很基础，但是感觉官方文档说的还是不够明了，尤其...

参考Drools官方文档(3.1 KIE Session和3.2 Inference and truth maintenance in the Drools engine)，学习关于Kie Session和Truth maintenace的内容。这两节内容虽然很基础，但是感觉官方文档说的还是不够明了，尤其是Stateless Session和Stateful Session的区别，和insert()和insertLogical()的区别，官方文档给出的样例没有很好的体现出来，下面我尝试用我自己的例子来理解一下

# 1 Stateless Session和Stateful Session的区别

按照官方解释，Stateless Session每次调用会话是独立的，不保存上次调用的数据状态，而Stateful Session正相反。相对来说，Stateful Session更加容易理解，也更为常用，我们先写一个Stateful Session的例子。
先定义一个Person类

package drools.samples.domain;

public class Person {
private String name;
private int age;

public Person(String name,int age){
this.name=name;
this.age=age;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getAge() {
return age;
}

public void setAge(int age) {
this.age = age;
}
}

再定义一个规则文件statefulSampleRule.drl，逻辑很简单，如果一个person小于18岁，打印"xxx is a child"，否则打印"xxx is a adult"。

package drools.samples.rules.statefulSampleRule

import drools.samples.domain.Person

rule "Age < 18"
when
$a : Person(age < 18) then System.out.println($a.getName()+" is a child");
end

rule "Age > 18"
when
$a : Person(age >= 18) then System.out.println($a.getName()+" is a adult");
end

在kmodule.xml里定义一个名为"statefulTest"的ksession

<?xml version="1.0" encoding="UTF-8"?>
<kmodule xmlns="http://www.drools.org/xsd/kmodule">
<kbase name="stateful" packages="drools.samples.rules.statefulSampleRule">
<ksession name="statefulTest"/>
</kbase>
</kmodule>

写个执行程序，我们先把这个person对象的年龄设成16，执行下rule，然后我们再动态地更新年龄为25，重新执行下rule

KieServices kieServices = KieServices.Factory.get();
KieContainer kContainer = kieServices.getKieClasspathContainer();
KieSession kSession = kContainer.newKieSession("statefulTest");

Person p1 = new Person("Tom", 16);
FactHandle factHandle=kSession.insert(p1);
kSession.fireAllRules();
p1.setAge(25);
kSession.update(factHandle, p1,"age");
kSession.fireAllRules();

运行结果

所以在一个stateful session里，允许我们更新fact的状态并重新触发规则evaluate。
我们继续写个stateless session的例子。定义一个规则文件statelessSampleRule.drl，其实和statefulSampleRule.drl一样

package drools.samples.rules.statelessSampleRule
import drools.samples.domain.Person
rule "Age < 18"
when
$a : Person(age < 18) then System.out.println($a.getName()+" is a child");
end

rule "Age > 18"
when
$a : Person(age >= 18) then System.out.println($a.getName()+" is a adult");
end

在kmodule.xml里定义一个名为"statelessTest"的ksession，主要加上"stateless"的属性

<kbase name="stateless" packages="drools.samples.rules.statelessSampleRule">
<ksession name="statelessTest" type="stateless"/>
</kbase>

执行程序和结果

KieServices kieServices = KieServices.Factory.get();
KieContainer kContainer = kieServices.getKieClasspathContainer();
StatelessKieSession kSession = kContainer.newStatelessKieSession("statelessTest");

Person p1 = new Person("Tom", 16);
kSession.execute(p1);

你可能会问为什么我没有在stateless的例子里去更新age，这是因为查看StatelessKieSession的接口，你会发现根本就不提供更新fact的操作，并且stateless session的接口只提供了execute接口，因此stateless session的不同点就表现在这里，你无法在一个stateless session里去更新fact，一个fact只会有一次存入Working memory的操作。
我看网上有人认为stateless session在执行规则时会忽略fact的更新从而不重新触发rule，在我看来不是这样的。我们修改下statelessSampleRule.drl

package drools.samples.rules.statelessSampleRule
import drools.samples.domain.Person

rule "Age < 18"
when
$a : Person(age < 18) then System.out.println($a.getName()+"'age is less 18");
end

rule "Age 16"
when
$a : Person(age == 16) then System.out.println($a.getName()+"'age is 16");
modify($a){setAge(25)} end rule "Age 25" when$a : Person(age == 25)
then
System.out.println($a.getName()+"'age is 25"); modify($a){setAge(17)}
end

在这个规则文件里，我们特意指定fact进行更新，看看stateless session会不会处理这种状况。执行结果：

可以看到stateless session仍然正确处理了中间的fact变化，结果其实和stateful session是一样的，stateless session只是在你第二次调execute时不会和第一次调execute有关联。

# 2 insert()和insertLogical()的区别

## 2.1 Inference

在Drools规则语法中，insert操作的目的是为了进行推断(inference)，即根据已有fact推断一些中间fact，由此进一步的决定action。站在程序员的角度，其实就相当于生成中间变量。例如我们现在要删选出名为Tom的child，我们可以这样写规则:

rule "A child named Tom"
when:
$p : Person(name=="Tom",age<18) then System.out.println("The child Tom is here"); end 这个规则的condition里有age和name两个判断条件，这样写在这个例子没问题，但是如果考虑规模的提升和后期的维护，我们应该拆成两个condition，那么我们就可以用insert在执行过程中生成中间fact。我们像下面这样写规则，注意IsChild我们同样需要在引擎外定义好。 rule "Age < 18" when$p : Person(age < 18)
then
insert(new IsChild($p)); System.out.println($p.getName()+" is a child");
end

rule "Name is Tom"
when:
$p : Person(name=="Tom") IsChild(person==$p)
then
System.out.println("The child Tom is here");
end

## 2.2 insertLogical

简单情况下，用insert就足够了，但更多的情况下应该用insertLogical方法。我们看看官网的说明：insertLogical执行逻辑插入操作，通过Drools内置的truth maintenance手段，当逻辑插入的fact不再满足规则的条件时将自动撤销(retracted)。依旧有点难以理解，而且如果你自己写demo测试的话很多时候用insertLogical和insert的结果是一样的。按照我的理解，这两者的关键区别是在是否自动撤销，也就是说用insert插入到Working memory的fact，除非你手动撤销，不然的话是一直存在的，你在更新一个fact后，更新前的状态仍然存在；而insertLogical则会自动撤销掉所有不满足规则条件的fact。

public class IsChild {
private Person person;

public IsChild(Person person){
this.person=person;
}
public Person getPerson() {
return person;
}

public void setPerson(Person person) {
this.person = person;
}
}

private Person person;

this.person=person;
}

public Person getPerson() {
return person;
}

public void setPerson(Person person) {
this.person = person;
}
}

规则文件：

rule "Age < 18"
when
$p : Person(age < 18) then insert(new IsChild($p));
System.out.println($p.getName()+" is a child"); end rule "Age >= 18" when$p : Person(age >= 18)
then
insert(new IsAdult($p)); System.out.println($p.getName()+" is a adult");
end

rule "no child fact now"
when
not(IsChild())
then
System.out.println("There is no child fact now");
end

然后我们输入一个16岁的person，执行后再更新成25岁再次执行：

KieServices kieServices = KieServices.Factory.get();
KieContainer kContainer = kieServices.getKieClasspathContainer();
KieSession kSession = kContainer.newKieSession("insertTest");

Person p1 = new Person("Tom", 16);

FactHandle factHandle=kSession.insert(p1);
kSession.fireAllRules();

p1.setAge(25);
kSession.update(factHandle, p1,"age");
kSession.fireAllRules();

可以看到运行的结果没有符合我们的预期，明明Tom的年龄更新成了25岁，引擎却没有输出"There is no child fact now"，也就是说仍然有IsChild的fact存在
我们再用insertLogicl重写下规则：

rule "Age < 18"
when
$p : Person(age < 18) then insertLogical(new IsChild($p));
System.out.println($p.getName()+" is a child"); end rule "Age >= 18" when$p : Person(age >= 18)
then
insertLogical(new IsAdult($p)); System.out.println($p.getName()+" is a adult");
end

rule "no child fact now"
when
not(IsChild())
then
System.out.println("There is no child fact now");
end

同样的主程序运行一遍，其效果如下：

可见逻辑插入会自动撤销掉IsChild的fact，其结果符合我们的预期。

展开全文
• contrast to extending such a database, we present a system to query whether it contains an arbitrary fact. This work can be thought of as re-casting open domain information extraction: rather than ...
• Horrible Truth Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100610 Description In a Famous TV Show “Find Out” there are n characters and...

Problem H. Horrible Truth

Time Limit: 1 Sec

Memory Limit: 256 MB

## 题目连接

http://codeforces.com/gym/100610

## Description

In a Famous TV Show “Find Out” there are n characters and only one Horrible Truth. To make the series breathtaking all way long, the screenplay writer decided that every episode should show exactly one important event. There are three types of the important events in this series: • character A finds out the Truth; • character A finds out that the other character B knows the Truth; • character A finds out that the other character B doesn’t know the Truth. Initially, nobody knows the Truth. All events must be correct, and every fact found out must be true. If some character finds out some fact, she cannot find it out once again. Moreover, to give the audience some sense of action, the writer does not want an episode to show the important event of the same type as in the previous episode. Your task is to determine the maximal possible number of episodes in the series and to create an example of a screenplay plan.

## Input

The only line of the input contains a single integer n — the number of characters in the TV show (1 ≤ n ≤ 100).

## Output

In the first line of the output file output a single integer k — the maximal possible number of episodes in the series. Then write k lines, each containing a description of an episode. For the episode in which character A (characters are numbered 1 through n) finds out the Truth, write the line “A 0”. For an episode in which character A finds out that character B knows the Truth, write the line “A B”. Similarly, for an episode in which character A finds out that character B doesn’t know the Truth, write the line “A -B”. If there are several plans providing the maximal possible number of episodes, output any one of them.

3

## Sample Output

13 2 -1 1 0 2 1 1 -2 3 1 3 -2 2 0 1 2 1 -3 3 2 2 -3 3 0 1 3

## HINT

题意

无良电视剧公司要来拍电视剧了

每集演一个故事，分别是叫做A知道，B知道A知道,B知道A不知道

要求每个人都不能在两集内做同样的事情

不能连续两集都是知道，或者知道别人知道，或者知道别人不知道

要求你合乎逻辑的情况下，最多演多少集

题解：

观察样例可以，第一回合嘲讽一下别人，第二回合就让人知道，然后就来回知道别人知道和知道别人不知道这样就好了……

瞎搞……

代码：

//qscqesze
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <bitset>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define maxn 110000
#define mod 1001
#define eps 1e-9
#define pi 3.1415926
int Num;
//const int inf=0x7fffffff;   //§ß§é§à§é¨f§³
const ll inf=999999999;
{
ll x=0,f=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
return x*f;
}
//*************************************************************************************

map< pair<int,int> ,int> H;
vector<pair<int,int> > V;
int main()
{ // horrible.out
freopen("horrible.in","r",stdin);
freopen("horrible.out","w",stdout);
int tot=0;
if(n==1)
{
printf("1\n");
printf("1 0\n");
return 0;
}
V.push_back(make_pair(2,-1));
for(int i=1;i<=n;i++)
{
V.push_back(make_pair(i,0));
int ttt = 0;
int flag  = 1;

while(flag)
{
flag=0;
ttt++;
if(ttt%2==1)
{
flag=0;
for(int ii=1;ii<=n;ii++)
{
if(i==ii)
continue;
if(H[make_pair(ii,i)])
continue;
H[make_pair(ii,i)]=1;
V.push_back(make_pair(ii,i));
flag=1;
break;
}
}
else
{
flag=0;
for(int jj=i+1;jj<=n;jj++)
{
for(int ii=1;ii<=n;ii++)
{
if(ii==jj)
continue;
if(H[make_pair(ii,-jj)])
continue;
H[make_pair(ii,-jj)]=1;
V.push_back(make_pair(ii,-jj));
flag=1;
break;
}
if(flag)
break;
}
}
}
}
printf("%d\n",V.size());
for(int i=0;i<V.size();i++)
printf("%d %d\n",V[i].first,V[i].second);

}

转载于:https://www.cnblogs.com/qscqesze/p/4783660.html

展开全文
• Lesson 37 - On Telling the Truth The Victorians, realizing that the greatest happiness accorded to man is that provided by a happy marriage, endeavoured to pretend that all their marriages were happy...

## Lesson 37 - On Telling the Truth

The Victorians, realizing that the greatest happiness accorded to man is that provided by a happy marriage, endeavoured to pretend that all their marriages were happy. We, for our part, admitting the fact that no feat of intelligence and character is so exacting as that required of two people who desire to live permanently together on a basis of amity, are obsessed by the problem of how to render the basic facts of cohabitation simpler and more reasonable, in order that unhappy marriages may less frequently result. The Victorians would have considered it 'painful' or 'unpleasant' were one to point out that only four marriages out of every ten are anything but forced servitudes. We ourselves start from this very assumption and try to build from it a theory of more sensible relations between the sexes. Of all forms of arrant untruthfulness Victorian optimism appears to me to have been the most cowardly and the most damaging.

Truth, therefore, is an attitude of the mind. It is important, if one does not wish to inconvenience and to bore one's friends, not to tell lies. But it is more important not to think lies, or to slide into those mechanical and untruthful habits of thought which are so pleasant and so easy as descents to mental ineptitude. The Victorian habit of mind (which I consider to have been a bad habit of mind) was unduly preoccupied by what was socially and morally convenient. Convenience is, however, in all affairs of life, an execrable test of value. One should have the courage to think uncomfortably, since it is only by rejecting the convenient that one can come to think the truth.

Not, after all, that there is any such thing as truth. At best we can approach to some relative approximation. On the other hand, there is surely such a thing as untruth. One is generally aware when one has said something, or acted in some way which has left on other people an impression not strictly in accordance with the facts. One is generally aware, also, when one has thrust aside an inconvenient thought and slid into its place another thought which is convenient. One's awareness in the former case is in general more acute than in the latter, since we are more on the look-out for the lies we utter than for those we merely think. In fact, however, it is the untruthful thought which is the more vicious of the two. Spoken lies are invariably tiresome and may actually be dishonest. But continuous lying in the mind, a disease to which the Anglo-Saxon is peculiarly exposed, spells the destruction of human thought and character.

HAROLD NICOLSON On Telling The TruthFebruary, 1930

参考译文——论讲真话

维多利亚女王时代的人认为，人生最大的幸福来自美满的婚姻，因而他们都竭力装成他们的婚姻是美满幸福的。就我们而言，我们承认夫妻若欲相敬如宾、白首偕老，必须要在智慧和性格方面下功夫。我们感到困难的问题是，如何使两性同居变得较简单和合理一些，以减少不幸婚姻的发生。如果现在有人指出，目前每10对夫妻中只有4对不是属于强制奴役式的，那么，维多利亚女王时代的人将会为此感到“痛苦”和“不悦”。我们自己就是从上述假定出发并力图根据这一假定创立一种较为明智的两性关系的理论。在所有的十足虚伪的例子中，在我看来，维多利亚女王时代的那种乐观主义是最为脆弱最为有害的。

因此说真话是一种思想品德。如果一个人不想给朋友带来不便的和烦恼，不撒谎是重要的。但更重要的是，不要想着撒谎或者不要滑入到无意识的不诚实的思维习惯中去，虽然这种不诚实的思维习惯极其轻松愉快，毋需动脑就能做到。维多利亚女王时代的思维习惯（我认为这是一种不良的思维习惯），是过份看重于社会和道德方面的便利。然而无论从生活的哪个方面来看，用是否方便来衡量价值，是个极为糟糕的方法。一个人应该有勇气去“困难地”思考，而不是贪图方便而轻松地思考，只有拒绝了便利才能得到真理。

说到底，真话这样的事情是不存在的。充其量我们只能做到大部分是真实的。另一方面，虚假这东西肯定是存在的。一个人说的某句话做的某件事，给人留下的印象是不是完全符合事实，他本人对此情况一般总是心中清楚的。同样，若一个人把不合意的想法丢弃一边而以合意的想法取而代之，他本人一般也是知道的。他对前一种情况的明了程度一般要比对后一种情况清晰得多，因为我们对于自己说出的谎话，总比仅仅是想说的谎话更为警觉。但是事实上，这两者中更为邪恶的是虚伪的想法。撒谎总是令人厌恶的，可能实际上是一种不诚实的行为。但是，在头脑里的不断撒谎（这是盎格鲁-撒克逊人特别易犯的毛病）会导致人们思想和性格的丧失。

参考资料：

http://www.bigear.cn/resdown-492-7777700004790.html

展开全文
• Well, there is not much to say about synchronous connections, they are very easy to implement, in fact once we have configured our NSURLRequest , we need one line of code to kick off the connection ...
• The simple truth is that even though you are not able to purchase a pair of this brand shoes presently due for their huge prices, you can still grasp the possiblity to benefit from the moment if you ...
• https://workmacro.com/instagram/truth-behind-follow-unfollow-method-instagram/ The follow/unfollow strategy is very common for those familiar with Instagram automation. It works by following ...
• http://www.extremetech.com/computing/51994-the-naked-truth-about-anisotropic-filtering In the seemingly never-ending quest for more perfect 3D rendering, numerous filtering techniques are used to map...
• But in fact, what this decision says is:when users need to provide photos or videos using third-party services, they can only choose the camera that comes with the system, not that Android 11 cannot ...
• Another good example of that Kerio team don’t know anything about NDIS development, it’s that fact that they’re just don’t know what to hook. Kerio Firewall hooks in NDIS_PROTOCOL_CHARACTERISTICS...
• While there may be much posturing and bragging about who is the best-trained and who is the most elite, the truth is that each of the five mentioned groups has a very selective process for ...
• Installed in his new office with the help of FBI Agent Ronald Sandoval (Von Flores), Boone was careful to conceal the fact that his Cyber-Viral Implant (CVI) had been modified by the Resistance, ...
• Anderson equally previously had basically no justification to make sure you guess of the fact that forms celeb may subsequently lash apart to protect against the dog. For that reason for ...
• fact that these parents found themselves in.Perhaps one could also argue that if this political disparity was rectified, so to would some of the resulting motives.But no, Horin would not bring ...
• Poll shows that many still do not know the truth about PETA Prompted by the recent fifth anniversary of the Great Piggly Wiggly Dumpster Incident of 2005, the Atlanta Animal Welfare Examiner conduc
• In fact, I’ll go further and say the ideal situation would be that you will not be able to stop yourself pursuing your passions. By this time you should know what your obsessions are. If you ...
• 原文：... 正文下面的评论还是很值得看地！！ The truth about synchronous NSURLConnection Posted on 27/04/2011 In this post, I’ll talk about
• Facebook, in fact, explicitly prevents Google's Web crawler from indexing its most meaningful content through its  robots.txt  file. It withholds its own social content from Google and then objects ...
• , you give the fact as it is, calling a spade a spade. You tell it bluntly – no hiding anything and no equivocating. That is, you don’t have to choose your words but simply give a straight forward ...
• Truth of Varying Shades: Analyzing Language in Fake News and Political Fact-Checking Authors: Hannah Rashkin, Eunsol Choi, Jin Yea Jang, Svitlana Volkova and Yejin Choi Word Embeddings based on ...
• Q: Does this come with easy instructions to follow?... In fact, there are some pictures to follow as well! I understand that most of this concept is foreign to most people. In fact, onl...
• 自然语言处理NLP星空智能对话机器人系列：深入理解Transformer自然语言处理 Training a GPT-2 language model Steps 10 目录 Step 10: Creating a training model directoryContext and completion examples星空智能...
• Rich feature hierarchies for accurate object detection and semantic segmentation；论文被引：14188(06/09/2020)
• But, in fact, Wang was bravely addressing an issue that surfaces almost every day in the Chinese media. He was taking a stand in the continuing battle between those who uphold academic and scientific...
• In fact, the gap between people is not big. There are not so many legends and dramas. Everything is reasonable and reasonable. People who can achieve success often keep a common heart, accept ...
• In the past three years, many things that seemed like fantasies have, in fact, become reality. Yet I worry that I am still relying too much on the ideas I had before starting the company, and haven'...

...