Open yejiwi opened 1 year ago
# build a net then train it.
def periodic(inputs): # just a function
inputs *= 2 * np.pi
out = tf.concat([tf.cos(inputs), tf.sin(inputs), tf.cos(2 * inputs), tf.sin(2 * inputs)], 1)
return out
def main(_,_):
net = MIONetIn4CartesianProd(
[m, w*2, w*2, m*2], [m, w*2, w*2, m*2],
[m*_r, w*2, w*2, m*2], [m*_r, w*2, w*2, m*2],
[2, w, w, m],
activation,
"Glorot normal")
net.apply_feature_transform(periodic) # without self
if model trained, just predict with model.preict(input_data),
because input feature layer is in the graph of the net.
# so, code may be like this:
y_pred = model.predict(X_add)
Hi, As suggested in the reply for #32, I modified the function
safe_test
y_pred.append(model.predict(dde.nn.tensorflow_compat_v1.nn.NN.apply_feature_transform(self,X_add)))
but it gives an error saying
TypeError: apply_feature_transform() missing 1 required positional argument: 'transform'
First of all, I am not sure if this is how I am supposed to change the code based on the answer for #32.
If I put
apply_feature_transform(self,X_add))
,and it gives
NameError: name 'self' is not defined
I see in nn.py, self is defined. What should I do in this case?
Please refer the full code below. Thanks.