0

I'm trying to do something that's pretty simple in keras with no success. I have an input X with size (?, 1452, 1). All I want to do is split this input to a vector of 1450 and a vector of 2 and deal with them seperately in the network. I tried:

X1 = X[:, 1450:1452, :]

X2 = X[:, 0:1450, :]

and then do whatever I want. It compiles fine until it gets to the line where I create the model. I get an error saying that my Tensor object doesn't have any attribute called _keras_history even though it does. So i'm guessing keras converts X1 and X2 to a regular tensor. so, I tried using Lambda layers in the following way:

X1 = Lambda(lambda x: X[:, 0:1450, :], output_shape=(1450, 1))(X)

after using this, the network compiled and trained completely fine, and the only problem was saving the model to json/yaml. It gave me an error in the copy.deepcopy part saying:

TypeError: can't pickle _thread.lock objects. after researching online

I found out there's a problem in saving Lambda layers to json for some reason.

Question: Do you know of any way to split the input in a normal way that would allow me to save the model later? Thanks!

aleksandrbel
  • 1,422
  • 3
  • 20
  • 38
toxin9
  • 81
  • 7

0 Answers0