问题描述
num_class_range = tf.range(0,self.num_class,delta=1,dtype=tf.float32,name='range')
doc_type_indices = num_class_range+(self.num_class*self.doc_type)
doc_type_indices = tf.dtypes.cast(doc_type_indices,tf.int32)
y_pred = tf.reshape(y_pred,tf.stack([self.batch_size,-1,self.num_class*self.num_doc_type]))
#add dims (20,1,25)
doc_type_expanded = tf.expand_dims(doc_type_indices,axis=1)
#repeat (20,25) to 128*64
doc_type_indices = tf.repeat(doc_type_expanded,num_rows*num_cols,axis=1)
doc_type_indices = tf.expand_dims(doc_type_indices,axis=3)
print("=================",self.doc_type.shape,"=============")
class_y_pred = tf.gather_nd(y_pred,doc_type_indices,batch_dims=0,name=None)
我正在尝试根据索引对参数进行切片,但是上面提到的代码向我显示了在线错误
indice.shape [-1]
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)