TensorType(float32, 3D) cannot store a value of dtype float64 without risking loss of precision

20 views
Skip to first unread message

Jichao Liu

unread,
Dec 31, 2019, 3:29:53 AM12/31/19
to theano-users
When I want to get dense layer from the network when doing train, got the following error. How do fix this?

My input: 
        self.input_var = T.tensor3('inputs')
        self.target_var = T.ivector('targets')

get out of dense layer:
        self.util_add_dense(self.dense1_sz)
        self.dense1_out = lasagne.layers.get_output(self.network, deterministic=True)

        self.dense1 = theano.function([self.input_var], [self.dense1_out])
         
in train function:

        dense1 = networkrel.dense1(inputs)

Traceback (most recent call last):
  File "relational_network.py", line 211, in <module>
    semantic_ae.network_train()
  File "relational_network.py", line 203, in network_train
    utility_train(self, self.training_inputs, self.training_targets, self.test_inputs, self.test_targets)
  File "/home/relational_network_utilities.py", line 91, in utility_train
    dense = networkrel.dense1(inputs, targets)
  File "/root/miniconda2/lib/python2.7/site-packages/theano/compile/function_module.py", line 813, in __call__
    allow_downcast=s.allow_downcast)
  File "/root/miniconda2/lib/python2.7/site-packages/theano/tensor/type.py", line 140, in filter
    raise TypeError(err_msg)
TypeError: Bad input argument to theano function with name "relational_network.py:113" at index 0 (0-based).
Backtrace when that variable is created:

  File "relational_network.py", line 209, in <module>
    semantic_ae.network_build_layers_v1()
  File "relational_network.py", line 104, in network_build_layers_v1
    self.network_inp_prepare()
  File "relational_network.py", line 89, in network_inp_prepare
    self.input_var = T.tensor3('inputs')
TensorType(float32, 3D) cannot store a value of dtype float64 without risking loss of precision. If you do not mind this loss, you can: 1) explicitly cast your data to float32, or 2) set "allow_input_downcast=True" when calling "function". Value: "array([[[0.        , 0.        , 0.        , ..., 0.        ,

Reply all
Reply to author
Forward
0 new messages