有一个关于加载稀疏数据的小片段,但我不知道如何使用它.
SparseTensors与队列不兼容.如果使用SparseTensors,则必须在批处理后使用tf.parse_example解码字符串记录(而不是在批处理之前使用tf.parse_single_example).
我想我真的不知道如何加载数据.
我想加载的数据是SVM Light格式
我想到的方法是将训练集转换为TFRecords文件格式,然后用tensorflow加载这个转换后的数据.问题是我不知道我应该如何格式化我的数据,以便tensorflow将其解析为sparseTensors.
下面是从选取的摘录一个 GitHub上可用的实施例:
def convert_to(images, labels, name):
num_examples = labels.shape[0]
if images.shape[0] != num_examples:
raise ValueError("Images size %d does not match label size %d." %
(images.shape[0], num_examples))
rows = images.shape[1]
cols = images.shape[2]
depth = images.shape[3]
filename = os.path.join(FLAGS.directory, name + '.tfrecords')
print('Writing', filename)
writer = tf.python_io.TFRecordWriter(filename)
for index in range(num_examples):
image_raw = images[index].tostring()
example = tf.train.Example(features=tf.train.Features(feature={
'height': _int64_feature(rows),
'width': _int64_feature(cols),
'depth': _int64_feature(depth),
'label': _int64_feature(int(labels[index])),
'image_raw': _bytes_feature(image_raw)}))
writer.write(example.SerializeToString())
writer.close()
Run Code Online (Sandbox Code Playgroud)
它将图像数据编码为一个大blob.与我的数据的不同之处在于并非每个功能都已填充.我可以以相同的方式保持我的数据,但我不确定这是使用这些功能的方式.
这可能无关紧要,因为另一方面我会解码一些东西但是有更好的方法来处理稀疏数据吗? …
我正在尝试与Arango组建一个单元测试设置.为此,我需要能够围绕每个测试重置测试数据库.
我知道我们可以直接从REST API中删除数据库,但文档中提到创建和删除可能"需要一段时间".
这是建议的方式来进行这种设置还是有一个AQL语句来做类似的事情?
我正在尝试在我以编程方式创建的 Github 版本上自动发布一些资产。
这是我的上传功能:
function uploadFile(fileName, uploadUrl, callback){
var uploadEndPoint = url.parse(uploadUrl.substring(0,uploadUrl.indexOf('{')));
options.host = uploadEndPoint.hostname;
options.path = uploadEndPoint.pathname+'?name=' + fileName;
options.method = 'POST';
options.headers['content-type'] = 'application/zip';
var uploadRequest = https.request(options, callback);
uploadRequest.on('error', function(e) {
console.log('release.js - problem with uploadRequest request: ' + e.message);
});
var readStream = fs.ReadStream(path.resolve(__dirname,'builds',fileName));
readStream.pipe(uploadRequest);
readStream.on('close', function () {
req.end();
console.log('release.js - ' + fileName + ' sent to the server');
});
}
Run Code Online (Sandbox Code Playgroud)
最后我得到 404 not found
我尝试从令牌和用户/密码进行身份验证
我检查了网址
我认为这可能是因为 SNI,但我不知道如何检查。
有什么线索吗?谢谢 !
我想将类的更新实例合并到基本实例中,如果基本实例中的该字段为"空",则选择基础实例上的更新实例的字段.以下示例合并base并update:
case class Foo(a: Option[Int], b: List[Int], c: Option[Int])
val base = Foo(None, Nil, Some(0))
val update = Foo(Some(3), List(4), None)
merge(base,update) == Foo(Some(3), List(4), Some(0))
Run Code Online (Sandbox Code Playgroud)
我尝试过这样的事情:
val g = Generic[Foo]
val aHList = g.to(base)
val bHList = g.to(update)
aHList
.zipWithIndex
.map({
case (l: List, i: Int) => l ++ bHList(i)
case (o: Option, i: Int) => if (!bHList(i).nonEmpty) {
updateHList(i)
} else {
o
}
case (_, i: Int) => updateHList(i)
})
Run Code Online (Sandbox Code Playgroud)
但事实证明,泛型.to方法不输出 …