question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ValueError: Unknown loss function:loss

See original GitHub issue

Hi @adalca ,

I have trained my own model 05.h5 via train.py(cvpr version), but when it used in python register.py --gpu 0 ../test_vol.nii.gz ../atlas_norm.nii.gz --out_img ../wrap.nii.gz --model_file ../models/05.h5 and an error occurred.

(voxelmorph) jasonfu@jasonfu-Z370-HD3:~/voxelmorph/src$ python register.py --gpu 0 ../IXI001.nii.gz ../atlas_norm.nii.gz --out_img ../wrap.nii.gz --model_file ../models/05.h5 
Using TensorFlow backend.
2019-09-01 21:06:02.075134: I tensorflow/core/platform/cpu_feature_guard.cc:140] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2019-09-01 21:06:02.144359: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:898] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2019-09-01 21:06:02.144634: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1356] Found device 0 with properties: 
name: GeForce GTX 1070 major: 6 minor: 1 memoryClockRate(GHz): 1.7845
pciBusID: 0000:01:00.0
totalMemory: 7.93GiB freeMemory: 7.74GiB
2019-09-01 21:06:02.144647: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1435] Adding visible gpu devices: 0
2019-09-01 21:06:02.373578: I tensorflow/core/common_runtime/gpu/gpu_device.cc:923] Device interconnect StreamExecutor with strength 1 edge matrix:
2019-09-01 21:06:02.373604: I tensorflow/core/common_runtime/gpu/gpu_device.cc:929]      0 
2019-09-01 21:06:02.373610: I tensorflow/core/common_runtime/gpu/gpu_device.cc:942] 0:   N 
2019-09-01 21:06:02.373697: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1053] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 7477 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1070, pci bus id: 0000:01:00.0, compute capability: 6.1)
Traceback (most recent call last):
  File "register.py", line 104, in <module>
    register(**vars(args))
  File "register.py", line 67, in register
    net = keras.models.load_model(model_file, custom_objects=custom_objects)
  File "/home/jasonfu/anaconda3/envs/voxelmorph/lib/python3.6/site-packages/keras/models.py", line 301, in load_model
    sample_weight_mode=sample_weight_mode)
  File "/home/jasonfu/anaconda3/envs/voxelmorph/lib/python3.6/site-packages/keras/engine/training.py", line 634, in compile
    loss_functions = [losses.get(l) for l in loss]
  File "/home/jasonfu/anaconda3/envs/voxelmorph/lib/python3.6/site-packages/keras/engine/training.py", line 634, in <listcomp>
    loss_functions = [losses.get(l) for l in loss]
  File "/home/jasonfu/anaconda3/envs/voxelmorph/lib/python3.6/site-packages/keras/losses.py", line 122, in get
    return deserialize(identifier)
  File "/home/jasonfu/anaconda3/envs/voxelmorph/lib/python3.6/site-packages/keras/losses.py", line 114, in deserialize
    printable_module_name='loss function')
  File "/home/jasonfu/anaconda3/envs/voxelmorph/lib/python3.6/site-packages/keras/utils/generic_utils.py", line 164, in deserialize_keras_object
    ':' + function_name)
ValueError: Unknown loss function:loss

I

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9

github_iconTop GitHub Comments

github_iconTop Results From Across the Web

ValueError: 'Unknown loss function' · Issue #5916 · keras-team ...
I trained and saved a model that uses a custom loss function (Keras version: 2.0.2): model.compile(optimizer=adam, ...
Read more >
keras "unknown loss function" error after defining custom loss ...
I defined a new loss function in keras in losses.py file. I close and relaunch anaconda prompt, but I got ValueError: ('Unknown loss...
Read more >
Custom loss function — DeepReg documentation
This tutorial will take an image intensity based loss function (mutual information) as an example to ... y_pred) else: raise ValueError("Unknown loss type....
Read more >
Losses - Keras
The purpose of loss functions is to compute the quantity that a model should seek to minimize during training. Available losses. Note that...
Read more >
CS50AI Project 5: Traffic , ValueError: Unknown loss function ...
CS50AI Project 5: Traffic , ValueError: Unknown loss function:categorial_crossentropy ... Anyone having the same problems as me? Code keeps giving ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found