Tensorflow 如何像决策树一样在keras函数API中插入逻辑语句?
假设以下网络Tensorflow 如何像决策树一样在keras函数API中插入逻辑语句?,tensorflow,keras,Tensorflow,Keras,假设以下网络 #sub model 1 i= Input() x=Dense(i) x=Dense(x) #output [N times 1] array 但是,在这一步中,应用一个函数 f([N times 1]) #return True or False 这样,如果f()返回1,那么 #sub model 2 y1=concentrate(Input, x) # i.e. Input and [N times 1] y1=Dense(y1) # notic
#sub model 1
i= Input()
x=Dense(i)
x=Dense(x) #output [N times 1] array
但是,在这一步中,应用一个函数
f([N times 1]) #return True or False
这样,如果f()返回1,那么
#sub model 2
y1=concentrate(Input, x) # i.e. Input and [N times 1]
y1=Dense(y1)
# notice that it's this dependence of the result from the previous network,
#i.e. [N times 1] made the importance of training the model as a whole.
如果f()返回0,则
#sub model 3
y1=Dense(Input)
y1=Dense(y1)
类似于决策树,但具有用户指定为函数f()的逻辑
问题:
子模型1=模型(i,x)
中的培训参数用于网络。如何实现这样的“模块化培训”
关于问题1的更新:这样的解决方案之一可能是。但是,这需要修改所有使用的层和最终层。有更好的方法吗?我不明白,您需要在运行时计算条件还是仅在实例化模型时计算条件?@BestDogeStackoverflow基本上是的。