技术标签: 深度学习如何跑视差图
机器学习是一种自动发现Data Fabric中隐藏的洞察(insight)的过程,它使用的算法能够发现这些洞察(insight),而无需专门为此编写程序,从而创建模型来解决特定(或多个)问题。理解这一点的前提是我们创建了一个Data Fabric。对我来说,最好的工具就是Anzo,正如我之前提到的。
深度学习是机器学习的一个特定子领域,是一种从数据中学习表示的新方法,强调学习越来越有意义的表示的连续“层”(神经网络)。在这里,我们将讨论深度学习和图论的结合,看看它如何帮助向前推进我们的研究。
https://towardsdatascience.com/how-to-do-deep-learning-on-graphs-with-graph-convolutional-networks-7d2250723780这里的重要部分是图神经网络(GNN)的概念。
https://community.platform.matrixds.com/community/project/5c6ae7c8c1b06ba1e18f2a6e/files通过点击:
sudo apt install graphviz libgraphviz-dev libcgraph6
然后安装库:
pip install spektral
例如,如果我们运行
from spektral.datasets import citation
adj, node_features, edge_features, _, _, _, _, _ = citation.load_data('cora')
我们将在sigle模式下加载数据,我们的邻接矩阵为:
In [3]: adj.shape
Out[3]: (2708, 2708)
节点属性为:
In [3]: node_attributes.shape
Out[3]: (2708, 2708)
边属性为:
In [3]: edge_attributes.shape
Out[3]: (2708, 7)
https://community.platform.matrixds.com/community/project/5c6ae7c8c1b06ba1e18f2a6e/filesGAT是一种新型的神经网络结构,它利用掩蔽的自注意层对图形结构数据进行操作。在Spektral中, GraphAttention层计算卷积与
layers.GraphConv
类似,但是使用注意机制来加权邻接矩阵,而不是使用归一化拉普拉斯。 它们的工作方式是通过堆叠节点能够参与其邻域特征的层,这使得(隐式)为邻域中的不同节点指定不同的权重,而不需要任何开销过大的矩阵操作(例如矩阵求逆)或是需要事先了解图形结构。
我们将使用的模型非常简单:
# Layers
dropout_1 = Dropout(dropout_rate)(X_in)
graph_attention_1 = GraphAttention(gat_channels,
attn_heads=n_attn_heads,
attn_heads_reduction='concat',
dropout_rate=dropout_rate,
activation='elu',
kernel_regularizer=l2(l2_reg),
attn_kernel_regularizer=l2(l2_reg))([dropout_1, A_in])
dropout_2 = Dropout(dropout_rate)(graph_attention_1)
graph_attention_2 = GraphAttention(n_classes,
attn_heads=1,
attn_heads_reduction='average',
dropout_rate=dropout_rate,
activation='softmax',
kernel_regularizer=l2(l2_reg),
attn_kernel_regularizer=l2(l2_reg))([dropout_2, A_in])# Build model
model = Model(inputs=[X_in, A_in], outputs=graph_attention_2)
optimizer = Adam(lr=learning_rate)
model.compile(optimizer=optimizer,
loss='categorical_crossentropy',
weighted_metrics=['acc'])
model.summary()# Callbacks
es_callback = EarlyStopping(monitor='val_weighted_acc', patience=es_patience)
tb_callback = TensorBoard(log_dir=log_dir, batch_size=N)
mc_callback = ModelCheckpoint(log_dir + 'best_model.h5',
monitor='val_weighted_acc',
save_best_only=True,
save_weights_only=True)
但是这个模型会很大:
__________________________________________________________________________________________________
Layer (type) Output Shape Param # Connected to
==================================================================================================
input_1 (InputLayer) (None, 1433) 0
__________________________________________________________________________________________________
dropout_1 (Dropout) (None, 1433) 0 input_1[0][0]
__________________________________________________________________________________________________
input_2 (InputLayer) (None, 2708) 0
__________________________________________________________________________________________________
graph_attention_1 (GraphAttenti (None, 64) 91904 dropout_1[0][0]
input_2[0][0]
__________________________________________________________________________________________________
dropout_18 (Dropout) (None, 64) 0 graph_attention_1[0][0]
__________________________________________________________________________________________________
graph_attention_2 (GraphAttenti (None, 7) 469 dropout_18[0][0]
input_2[0][0]
==================================================================================================
Total params: 92,373
Trainable params: 92,373
Non-trainable params: 0
所以如果机器性能没有那么好的话,可以减少epochs的次数。然后我们训练它(如果机器性能不够好,这可能需要几个小时):
# Train model
validation_data = ([node_features, adj], y_val, val_mask)
model.fit([node_features, adj],
y_train,
sample_weight=train_mask,
epochs=epochs,
batch_size=N,
validation_data=validation_data,
shuffle=False, # Shuffling data means shuffling the whole graph
callbacks=[es_callback, tb_callback, mc_callback])
得到最好的模型: model.load_weights(log_dir + 'best_model.h5')
评估模型:
print('Evaluating model.')
eval_results = model.evaluate([node_features, adj],
y_test,
sample_weight=test_mask,
batch_size=N)
print('Done.\n''Test loss: {}\n''Test accuracy: {}'.format(*eval_results))
更多的信息可以参见MatrixDS项目:
https://community.platform.matrixds.com/community/project/5c6ae7c8c1b06ba1e18f2a6e/files
并且存储的是一系列文件:
ind.dataset_str.x => the feature vectors of the training instances as scipy.sparse.csr.csr_matrix object; ind.dataset_str.tx => the feature vectors of the test instances as scipy.sparse.csr.csr_matrix object; ind.dataset_str.allx => the feature vectors of both labeled and unlabeled training instances (a superset of ind.dataset_str.x) as scipy.sparse.csr.csr_matrix object; ind.dataset_str.y => the one-hot labels of the labeled training instances as numpy.ndarray object; ind.dataset_str.ty => the one-hot labels of the test instances as numpy.ndarray object; ind.dataset_str.ally => the labels for instances in ind.dataset_str.allx as numpy.ndarray object; ind.dataset_str.graph => a dict in the format {index: [index_of_neighbor_nodes]} as collections.defaultdict object; ind.dataset_str.test.index => the indices of test instances in graph, for the inductive setting as list object.
这些数据在图中,我们所做的就是把数据加载到库中。实际上,可以将数据转换为库中的NetworkX,numpy和sdf格式。
这意味着,如果我们将数据存储在一个Data Fabric中,我们就有了我们的知识图谱,因此我们已经有了很多这些特征,我们要做的就是找到一种方法,把它与库连接起来。这是现在最棘手的部分。 然后我们通过对Data Fabric内部的图运行深度学习算法的过程,开始在Data Fabric中寻找洞察(insight)。 这里有趣的部分是,可能有一些方法可以在图中运行这些算法,为了实现这一点,我们需要能够使用存储在图形结构中的固有数据来构建模型,Lauren Shin 的Neo4j有一个非常有趣的方法:https://towardsdatascience.com/graphs-and-ml-multiple-linear-regression-c6920a1f2e70但这项工作仍在进行中。我想象这个过程是这样的:
https://arxiv.org/pdf/1812.04202.pdf。
☆☆☆为方便大家查阅,小编已将知识图谱实战进阶系列文章统一整理到公众号底部菜单栏,同步更新中,关注公众号,点击左下方“系列文章”,如图:
欢迎大家和我一起沿着知识图谱进阶专栏这条路线,一起巩固机器学习算法基础。(添加微信:mthler,开启打怪升级的学习之旅。)
游戏发布后,loading与活动页面会经常有更新需求,所以考虑加入lua脚本,部分常变动面板使用lua开发,到达动态更新目的。学习过程中遇到一个问题,使用下面方法调用lua脚本,IOS正常,但是android平台,第一次可以正常显示,第二次失败。 // register lua engine CCLuaEngine* pEngine = CCLuaEngine:
在CSS3中,可以利用transform功能来实现文字或图像的旋转、缩放、倾斜、移动这四种类型的变形处理。注意:都是以中心点为原点进行移动旋转缩放倾斜的。skew的默认原点是transform-origin是这个物件的中心点。transform-origin:设置元素原点位置;transform-origin:50% 50% 0;默认值X轴方向:left | center | ...
卷积神经网络LeNet-5的RTL实现(一)前言毕业设计做的是卷积神经网络硬件加速相关内容,需要在ZYNQ7020平台上实现一个卷积神经网络。搜索资料的时候发现网上用RTL实现卷积神经网络的资料并不多,于是打算开个博客记录下项目实现过程。由于刚接触数字设计不久,在设计思路和具体实现方面还有许多不足,希望和大家一起交流进步。本系列博客包含六期内容,分别如下:前言以及项目用到的结构性电路介绍...
为什么80%的码农都做不了架构师?>>> ...
controller用来完成接口的任务,而controller方法内重构出来的业务放在support类中。之前项目的做法:将在contoller里面的service传过去做具体业务。现在忽然不想带这个service了,就将具体service放到controller的support中去了。controller的support类@Componentpublic class FeeC...
转自:http://key.cx/1397.html
android textView 中英文混排导致的自动换行出现的混乱的解决方案。package com.zhaoshebei.ui.custom;import android.annotation.SuppressLint;import android.content.Context;import android.graphics.Canvas;import android.os
软件构造复习1目录软件构造中的多维度视图Built-time 构造阶段Run-time 运行阶段软件构造的质量目标目录软件构造中的多维度视图按阶段划分:构造时/运行时视图按动态性划分:时刻/阶段视图按构造对象的层次划分:代码/构件视图Software=Modules(Components)+Data/Control Flows软件的质量目标评价不能脱离外部环境开发软件的流程计划-分析-设计-完善-测试&融合-维护Built-time 构造阶段代码层——代码的
这是主题为《面向交互的人工智能》的分享。主要讲解了语音交互中用到的 AI 技术,如 ASR、NLU、NLG、TTS 等,以及基于这些细分技术构建的面向对话式的人工智能操作系统——DuerOS。通过本次分享大家可以基本上掌握如何在智能语音交互平台上开发应用,进一步体会智能语音如何服务我们的生活。1语音使人机交互更加便捷什么是交互?交互是指 A 和 B 之间的一系列动作和行为...
collect_set无法满足业务需要,只排重不排序。为了实现又排重又排序,重写了collect_set的底层源码。其实就是把底层的LinkHashSet改成TreeSet。涉及到的类org.apache.hadoop.hive.ql.udf.generic.GenericUDAFCollectSet;org.apache.hadoop.hive.ql.udf.generic.Generi...
在spring-mvc.xml 文件中添加下面代码<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"></bean>添加后重新运行项目 成功看到页面
find_package1.两种模式Moudule模式:搜索CMAKE_MODULE_PATH指定路径下或者自己的模块目录下的FindXXX.cmake文件。Config模式:搜索指定路径下的XXXConfig.cmake或者XXX-config.cmake文件。2.寻找到之后将定义以下常用变量<LibaryName>_FOUND<LibaryName>_INCLUDE_DIR or <LibaryName>_INCLUDES <LibaryNa