question on trax
joseph pareti
joepareti54 at gmail.com
Tue Aug 17 11:50:59 EDT 2021
In the following code, where does tl.Fn come from? i see it nowhere in the
documents, i.e I was looking for trax.layers.Fn :
import numpy as np
*from trax import layers as tl*
from trax import shapes
from trax import fastmath
#
def Addition():
layer_name = "Addition" # don't forget to give your custom layer a
name to identify
# Custom function for the custom layer
def func(x, y):
return x + y
return *tl.Fn*(layer_name, func)
# Test it
add = Addition()
# Inspect properties
print("-- Properties --")
print("name :", add.name)
print("expected inputs :", add.n_in)
print("promised outputs :", add.n_out, "\n")
# Inputs
x = np.array([3])
y = np.array([4])
print("-- Inputs --")
print("x :", x, "\n")
print("y :", y, "\n")
# Outputs
z = add((x, y))
print("-- Outputs --")
print("z :", z)
--
Regards,
Joseph Pareti - Artificial Intelligence consultant
Joseph Pareti's AI Consulting Services
https://www.joepareti54-ai.com/
cell +49 1520 1600 209
cell +39 339 797 0644
More information about the Python-list
mailing list