calico / borzoi

RNA-seq prediction with deep convolutional neural networks.
Apache License 2.0
80 stars 10 forks source link

Exception encountered when calling layer "ensemble_shift" (type EnsembleShift). #21

Open Delayed-Gitification opened 3 months ago

Delayed-Gitification commented 3 months ago

Hi,

Thanks for making this public and for the jupyter notebook examples.

When running borzoi_example_eqtl_chr10_116952944_T_C I get the following error in the Model Configuration section:

`TypeError Traceback (most recent call last) Cell In[6], line 45 43 if rc : 44 seqnn_model.strand_pair.append(slice_pair) ---> 45 seqnn_model.build_ensemble(rc, '0') 47 models.append(seqnn_model)

File /nemo/lab/ulej/home/users/wilkino/POSTDOC/borzoi/baskerville/src/baskerville/seqnn.py:232, in SeqNN.build_ensemble(self, ensemble_rc, ensemble_shifts) 228 sequences = [sequence] 230 if shift_bool: 231 # generate shifted sequences --> 232 sequences = layers.EnsembleShift(ensemble_shifts)(sequences) 234 if ensemble_rc: 235 # generate reverse complements and indicators 236 sequences_rev = layers.EnsembleReverseComplement()(sequences)

File /camp/lab/ulej/home/shared/Oscar/.conda/envs/borzoi/lib/python3.9/site-packages/keras/src/utils/traceback_utils.py:70, in filter_traceback..error_handler(*args, **kwargs) 67 filtered_tb = _process_traceback_frames(e.traceback) 68 # To get the full stack trace, call: 69 # tf.debugging.disable_traceback_filtering() ---> 70 raise e.with_traceback(filtered_tb) from None 71 finally: 72 del filtered_tb

File /tmp/slurm_5811498/autograph_generated_fileqxewtxl3.py:49, in outer_factory..inner_factory..tfcall(self, seqs_1hot) 47 seq_1hot = ag.Undefined('seq_1hot') 48 shift = ag.Undefined('shift') ---> 49 ag.for_stmt(ag.ld(seqs_1hot), None, loop_body_1, get_state_2, set_state_2, (), {'iterate_names': 'seq_1hot'}) 50 try: 51 do_return = True

File /tmp/slurm_5811498/autograph_generated_fileqxewtxl3.py:46, in outer_factory..inner_factory..tfcall..loop_body_1(itr_1) 44 shift = itr 45 ag.converted_call(ag.ld(ens_seqs_1hot).append, (ag.converted_call(ag.ld(shift_sequence), (ag.ld(seq_1hot), ag.ld(shift)), None, fscope),), None, fscope) ---> 46 ag.for_stmt(ag.ld(self).shifts, None, loop_body, get_state_1, set_state_1, (), {'iterate_names': 'shift'})

File /tmp/slurm_5811498/autograph_generated_fileqxewtxl3.py:45, in outer_factory..inner_factory..tfcall..loop_body_1..loop_body(itr) 43 def loop_body(itr): 44 shift = itr ---> 45 ag.converted_call(ag.ld(ens_seqs_1hot).append, (ag.converted_call(ag.ld(shift_sequence), (ag__.ld(seq_1hot), ag__.ld(shift)), None, fscope),), None, fscope)

File /tmp/slurm_5811498/autograph_generated_file3dipcnvq.py:31, in outer_factory..inner_factory..tfshift_sequence(seq, shift, pad_value) 29 ag.if_stmt(ag__.ld(seq).shape.ndims != 3, if_body, else_body, get_state, set_state, (), 0) 30 input_shape = ag.ld(seq).shape ---> 31 pad = ag.ld(pad_value) * ag__.converted_call(ag.ld(tf).ones_like, (ag.ld(seq)[:, 0:ag.converted_call(ag.ld(tf).abs, (ag.ld(shift),), None, fscope), :],), None, fscope) 33 @ag.autograph_artifact 34 def _shift_right(_seq): 35 with ag.FunctionScope('_shift_right', 'fscope_1', ag__.STD) as fscope_1:

TypeError: Exception encountered when calling layer "ensemble_shift" (type EnsembleShift).

in user code:

File "/nemo/lab/ulej/home/users/wilkino/POSTDOC/borzoi/baskerville/src/baskerville/layers.py", line 1063, in call  *
    ens_seqs_1hot.append(shift_sequence(seq_1hot, shift))
File "/nemo/lab/ulej/home/users/wilkino/POSTDOC/borzoi/baskerville/src/baskerville/layers.py", line 1121, in shift_sequence  *
    pad = pad_value * tf.ones_like(seq[:, 0 : tf.abs(shift), :])

TypeError: Value passed to parameter 'x' has DataType string not in list of allowed values: bfloat16, float16, float32, float64, int8, int16, int32, int64

Call arguments received by layer "ensemble_shift" (type EnsembleShift): • seqs_1hot=['tf.Tensor(shape=(None, 524288, 4), dtype=float32)']`

Delayed-Gitification commented 3 months ago

I think I possibly fixed this by changing '0' to [0] in the below line

seqnn_model.build_ensemble(rc, '0')

Is this valid, or would I be causing an issue by doing this? Thanks!

Delayed-Gitification commented 3 months ago

I've made a PR