File ‹Tools/TensorFlow_Digraph_Term.ML›
structure TensorFlow_Digraph_Term:TENSORFLOW_DIGRAPTH_TERM = struct
open Activation_Term
open Convert_TensorFlow_Json
val mk_nat = HOLogic.mk_number \<^typ>‹nat›
val mk_real = Nano_Json_Type.term_of_real
fun term_of_neuron _ Single (In uid) = @{const ‹NN_Digraph.neuron.In›(‹real›,‹activation⇩s⇩i⇩n⇩g⇩l⇩e›)}$(mk_nat uid)
| term_of_neuron _ _ (In uid) = @{const ‹NN_Digraph.neuron.In›(‹real›,‹activation⇩m⇩u⇩l⇩t⇩i›)}$(mk_nat uid)
| term_of_neuron _ Single (Out uid) = @{const ‹NN_Digraph.neuron.Out›(‹real›,‹activation⇩s⇩i⇩n⇩g⇩l⇩e›)}$(mk_nat uid)
| term_of_neuron _ _ (Out uid) = @{const ‹NN_Digraph.neuron.Out›(‹real›,‹activation⇩m⇩u⇩l⇩t⇩i›)}$(mk_nat uid)
| term_of_neuron verbose Single (Neuron {phi:TensorFlow_Type.activationT, bias:IEEEReal.decimal_approx, uid:int})
= (@{const ‹NN_Digraph.neuron.Neuron›(‹real›,‹activation⇩s⇩i⇩n⇩g⇩l⇩e›)} $
(@{const ‹NN_Digraph.Neuron.Neuron_ext›(‹activation⇩s⇩i⇩n⇩g⇩l⇩e›,‹real›,‹unit›)} $
(term_of_activation_single phi) $ (mk_real verbose (Real.toDecimal 1.0))
$ (mk_real verbose bias)$ (mk_nat uid) $ @{Const ‹Unity›}))
| term_of_neuron verbose _ (Neuron {phi:TensorFlow_Type.activationT, bias:IEEEReal.decimal_approx, uid:int})
= (@{const ‹NN_Digraph.neuron.Neuron›(real,‹activation⇩m⇩u⇩l⇩t⇩i›)} $
(@{const ‹NN_Digraph.Neuron.Neuron_ext›(‹activation⇩m⇩u⇩l⇩t⇩i›,‹real›,‹unit›)} $
(term_of_activation_multi phi) $ (mk_real verbose (Real.toDecimal 1.0))
$ (mk_real verbose bias)$ (mk_nat uid) $ @{Const ‹Unity›}))
end