本篇深入分析郭大nffm的代码

TensorFlow计算图

计算图的构建

ones = tf.ones_like(emb_inp_v2)
mask_a = tf.matrix_band_part(ones, 0, -1) # Upper triangular matrix of 0s and 1s
mask_b = tf.matrix_band_part(ones, 0, 0) # Diagonal matrix of 0s and 1s
mask = tf.cast(mask_a - mask_b, dtype=tf.bool) # Make a bool mask
'''
True - True = 0 and 0 = False
''' #DNN
dnn_input = tf.boolean_mask(emb_inp_v2, mask) # 把上三角减去对角线的部分取出来
dnn_input = tf.reshape(dnn_input,[tf.shape(emb_inp_v2)[0],hparams.feature_nums*(hparams.feature_nums-1)//2]) input_size=int(dnn_input.shape[-1])
for idx in range(len(hparams.hidden_size)):
glorot = np.sqrt(2.0 / (input_size + hparams.hidden_size[idx]))
W = tf.Variable(np.random.normal(loc=0, scale=glorot, size=(input_size, hparams.hidden_size[idx])), dtype=np.float32)
dnn_input=tf.tensordot(dnn_input,W,[[-1],[0]])
if hparams.norm is True:
dnn_input=self.batch_norm_layer(dnn_input,\
self.use_norm,'norm_'+str(idx))
dnn_input=tf.nn.relu(dnn_input)
input_size=hparams.hidden_size[idx] glorot = np.sqrt(2.0 / (hparams.hidden_size[-1] + 1))
W = tf.Variable(np.random.normal(loc=0, scale=glorot, size=(hparams.hidden_size[-1], 1)), dtype=np.float32)
b = tf.Variable(tf.constant(-3.5), dtype=np.float32)
w3=tf.tensordot(dnn_input,W,[[-1],[0]])+b

为什么没有把单项特征算进去?

最新文章

  1. 怎样学习Java
  2. poj 2251 Dungeon Master
  3. 绑定本地Service并与之通信-----之一
  4. 在eclipse中生成html注释文档
  5. What is Object Oriented Design? (OOD)
  6. 各种电子面单_Api接口
  7. 右下角显示提示窗口(New-Object,COM)
  8. Linux学习笔记22——线程属性(转)
  9. 禁止root远程登录 sshd问题:A protocol error occurred. Change of username or service not allowed
  10. DOM树节点和事件
  11. 初识WCF之使用配置文件部署WCF应用程序
  12. How do I copy files that need root access with scp
  13. 前端知识之Ajax
  14. 5行代码实现微信小程序图片上传与腾讯免费5G存储空间的使用
  15. vue2 学习笔记2
  16. qt5下载与安装,VS2017的环境配置
  17. Imageview 按比例适应屏幕大小
  18. ISO 8601: Delphi way to convert XML date and time to TDateTime and back (via: Stack Overflow)
  19. windows自带杀毒防火墙
  20. 命名实体识别(NER)

热门文章

  1. linux脚本监控应用且通过邮件报警异常
  2. H-ui前端框架,后端模板
  3. editormd 富文本编辑器转 html
  4. SpringBoot与缓存、消息、检索、任务、安全与监控
  5. python读取ubuntu系统磁盘挂载情况
  6. 【Day4】3.urllib模块使用案例
  7. 【异常】ssh无法登录验证,非root用户ssh本机无法成功
  8. XXX_initcall()函数分析
  9. 2.06_Python网络爬虫_正则表达式
  10. Linux搭建.net core CI/CD环境