diff --git a/model.ml b/model.ml
index 528ec20150e8119f9ebe12db866fb479aa806259..5099109c5a91cd8f04477561be45bd17c6418bdb 100644
--- a/model.ml
+++ b/model.ml
@@ -40,8 +40,8 @@ let nnet_delimiter = Str.regexp ","
 (* Parse a single Nnet format line: split line using [nnet_delimiter] as
    delimiter, and convert each string into a number by means of converter [f]. *)
 let handle_nnet_line ~f line =
-  List.map
-    ~f:(fun s -> f (String.strip s))
+  List.filter_map
+    ~f:(fun s -> try Some (f (String.strip s)) with _ -> None)
     (Str.split nnet_delimiter line)
 
 (* Skip the header part, ie comments, of the Nnet format. *)