我想这更像是一个公开咆哮,但为什么我不能用c#来推断我的Id类型?
public EntityT Get<EntityT>(IdT id) where EntityT : EntityObject<IdT>
Run Code Online (Sandbox Code Playgroud)
和Guid作为Id的已定义EntityObject如下:
public Foo : EntityObject<Guid>
Run Code Online (Sandbox Code Playgroud)
继承自如下定义的抽象EntityObject类:
public abstract class EntityObject<IdT>
{
public IdT id { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
get方法的用法如下:
IRepository repository = new Repository();
var hydratedFoo = repository.Get<Foo>(someGuidId);
Run Code Online (Sandbox Code Playgroud)
编辑以提供进一步的说明.
InfModel infmodel = ModelFactory.createInfModel(reasoner, m);
Resource vegetarian = infmodel.getResource(source + "Vegetarian");
Resource margherita = infmodel.getResource(source + "Example-Margherita");
if (infmodel.contains(margherita, RDF., vegetarian)) {
System.out.println("Margherita is a memberOf Vegetarian pizza");
}
Run Code Online (Sandbox Code Playgroud)
上面给出的例子是由正式的pizza.owl形成的.在这只猫头鹰中,Example-Margherita是Margherita类的一个人.所以,它已经写在owl文件中了.然而,问题在于推理者应该推断出margherita例子也应该是素食披萨.任何人都可以举个例子来说明如何找到像Protege这样的个体可能的推断类吗?(Protege正确地推断出Example-Margherita是一个素食比萨饼.但是,我不能以编程方式推断)
我正在构建一个需要拍摄图像并推断与之相关的标签的应用程序.这些标签可以是与图片相关的事物,形容词甚至情感.
我已经找到了ALIPR.但我测试了它,其他一些人也测试了它,它表现不佳.ALIPR在15个预测标签的集合中犯了太多错误.至少对于我的应用程序,最好只有几个但正确的标签.
优选地,API应该是基于网络的并且是免费的.有什么建议?
提前致谢!
tagging annotations inference image-processing photo-tagging
常见的相等/比较成员设计指南是不在可变引用类型上实现结构相等,而是查看具有可变字段的F#记录类型:
type Value = { mutable value: int }
let mutableRecord = { value = 1 }
let xs = Map.ofList [ mutableRecord, "abc"
{ value = 2 }, "def" ]
let abc = Map.find { value=1 } xs
mutableRecord.value <- 3
let abc = Map.find { value=3 } xs // KeyNotFoundException!
Run Code Online (Sandbox Code Playgroud)
它Map是内部排序的,但是mutable记录字段允许我更改排序,而记录实例已经在map中,这非常糟糕.
我认为F#应该推断[<NoEquality>]和[<NoComparison>]声明可变字段的F#记录类型的模式,不是吗?
我想使用Jena的推理功能,但是当我使用InfModel时,我遇到了一些性能问题.
以下是我的本体的简要概述:
属性:
hasX (Ranges(intersection): X, inverse properties: isXOf)
|-- hasSpecialX (Ranges(intersection): X, inverse properties: isSpecialXOf)
isXOf (Domains(intersection): X, inverse properties: hasX)
|--isSpecialXOf (Domains(intersection): X, inverse properties: hasSpecialX)
Run Code Online (Sandbox Code Playgroud)
此外还有一个"对象"类:
Object hasSpecialX some X
Run Code Online (Sandbox Code Playgroud)
显式存储的是以下数据:
SomeObject a Object
SomeX a X
SomeObject hasSpecialX SomeX
Run Code Online (Sandbox Code Playgroud)
使用以下查询,我想确定一个实例属于哪个类.根据所做的假设,只应返回'SomeObject'.
SELECT ?x WHERE { ?x :hasX :SomeX . }
Run Code Online (Sandbox Code Playgroud)
但是,查询ds.getDefaultModel()不起作用,因为数据未显式存储.infModel另一方面,当我使用时,查询永远不会完成.最长的我在流产前等了25分钟.(三元店的大小约为180 MB)
这是我的代码:
OntModel ont = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, null);
ont.read("file:..." , "RDF/XML");
Reasoner reasoner = ReasonerRegistry.getOWLMicroReasoner();
reasoner = reasoner.bindSchema(ont);
Dataset dataset = TDBFactory.createDataset(...);
Model …Run Code Online (Sandbox Code Playgroud) 我正在使用自定义图像集来使用Tensorflow API训练神经网络.在成功的训练过程之后,我得到这些检查点文件,其中包含不同训练var的值.我现在想从这些检查点文件中获取推理模型,我找到了这个脚本,然后我可以使用它来生成深度图像,如本教程中所述.问题是当我使用以下方式加载模型时:
import tensorflow as tf
model_fn = 'export'
graph = tf.Graph()
sess = tf.InteractiveSession(graph=graph)
with tf.gfile.FastGFile(model_fn, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
t_input = tf.placeholder(np.float32, name='input')
imagenet_mean = 117.0
t_preprocessed = tf.expand_dims(t_input-imagenet_mean, 0)
tf.import_graph_def(graph_def, {'input':t_preprocessed})
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
graph_def.ParseFromString(f.read())
self.MergeFromString(连载)
raise message_mod.DecodeError('Unexpected end-group tag.')google.protobuf.message.DecodeError:意外的端组标记.
该脚本需要一个协议缓冲区文件,我不确定我用来生成推理模型的脚本是否给我原型缓冲区文件.
有人可以建议我做错了什么,或者有更好的方法来实现这一目标.我只想将张量生成的检查点文件转换为proto缓冲区.
谢谢
inference machine-learning protocol-buffers tensorflow tensorflow-serving
以这篇 StackOverflow 文章为例,我实现了一个类型化事件系统。简化后,它看起来像:
interface MyTypeMap {
FOO: string;
BAR: number;
}
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用此地图创建一个事件处理程序:
function handleEvent<T extends keyof MyTypeMap>(eventKey: T, eventMsg: MyTypeMap[T]) {
switch(eventKey) {
case('FOO'):
// TS believes that eventKey is of type 'never'
// TS believes that eventMsg is 'string|number'
break;
case('BAR'):
// TS believes that eventKey is of type 'never'
// TS believes that eventMsg is 'string|number'
break;
}
}
Run Code Online (Sandbox Code Playgroud)
当外部调用此函数时,TypeScript 的行为与预期一致。例如:
// These work as desired
handleEvent('FOO', 'asdf');
handleEvent('BAR', 5);
// These throw compile errors as …Run Code Online (Sandbox Code Playgroud) 从https://github.com/Microsoft/TypeScript/pull/3622:
超类型折叠:如果 B 是 A 的超类型,则 A & B 等价于 A。
然而:
type a = string & any; // Resolves to any, not string!?
Run Code Online (Sandbox Code Playgroud)
这个交集解析为任何。'any' 不是字符串的超类型吗?那么由于超类型折叠,这个交集不应该只是字符串吗?我错过了什么?
这里的用例是这样的:
type PropertyMap = {
prop1: {
name: "somename";
required: any;
};
prop2: {
name: "someothername";
required: never;
}
}
type RequiredOnly = {
[P in keyof PropertyMap]: PropertyMap[P] & PropertyMap[P]["required"]
}
// RequiredOnly["prop2"] correctly inferred to be never, but we've
// lost the type info on prop1, since it is now …Run Code Online (Sandbox Code Playgroud) 有没有办法检测加载为 TF 保存模型的第一个或最后一个格式的通道model=tf.saved_model.load(path)?
在 Keras 中,可以model.layers检查层 ll.data_format == 'channels_last'
TF保存的模型有这样的东西吗?我找不到任何合适的 TF 模型细节文档——一切都可以追溯到 Keras。
我做了一个项目,基本上使用谷歌对象检测 API 和张量流。
我所做的就是使用预先训练的模型进行推理:这意味着实时对象检测,其中输入是网络摄像头的视频流或使用 OpenCV 的类似内容。
现在我得到了相当不错的性能结果,但我想进一步提高 FPS。
因为我的经验是,Tensorflow 在推理时使用了我的整个内存,但 GPU 使用率根本没有达到最大值(NVIDIA GTX 1050 笔记本电脑上约为 40%,NVIDIA Jetson Tx2 上约为 6%)。
所以我的想法是通过增加每个会话运行中输入的图像批量大小来增加 GPU 使用率。
所以我的问题是:在将输入视频流的多个帧提供给之前,如何将它们一起批处理sess.run()?
查看我object_detetection.py的 github 存储库上的代码:( https://github.com/GustavZ/realtime_object_detection )。
如果您能提出一些提示或代码实现,我将非常感激!
import numpy as np
import os
import six.moves.urllib as urllib
import tarfile
import tensorflow as tf
import cv2
# Protobuf Compilation (once necessary)
os.system('protoc object_detection/protos/*.proto --python_out=.')
from object_detection.utils import label_map_util
from object_detection.utils import visualization_utils as vis_util
from stuff.helper import FPS2, WebcamVideoStream
# INPUT PARAMS
# Must …Run Code Online (Sandbox Code Playgroud) opencv inference video-processing object-detection tensorflow
inference ×10
tensorflow ×3
generics ×2
jena ×2
typescript ×2
annotations ×1
any ×1
c# ×1
comparison ×1
equality ×1
f# ×1
intersection ×1
mutable ×1
ontology ×1
opencv ×1
owl ×1
protege ×1
sparql ×1
tagging ×1
types ×1
typing ×1