Skip to content

Commit b9e0d8e

Browse files
authored
Merge pull request yahoo#140 from yahoo/cos_exception_handling
Exception Handling cos
2 parents 10e9840 + 53d6b52 commit b9e0d8e

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

‎caffe-grid/src/main/scala/com/yahoo/ml/caffe/CaffeOnSpark.scala‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ object CaffeOnSpark {
5050
//training if specified
5151
val caffeSpark = new CaffeOnSpark(sc)
5252
if (conf.isTraining ){
53-
if (conf.solverParameter.hasTestInterval && (conf.solverParameter.getTestIter(0) != 0)) {
53+
if (conf.solverParameter.hasTestInterval && (conf.solverParameter.getTestInterval() != 0) && (conf.solverParameter.getTestIter(0) != 0)) {
5454
val sourceTrain: DataSource[Any,Any] = DataSource.getSource(conf, true).asInstanceOf[DataSource[Any, Any]]
5555
val sourceValidation: DataSource[Any,Any] = DataSource.getSource(conf, false).asInstanceOf[DataSource[Any, Any]]
5656
caffeSpark.trainWithValidation(sourceTrain, sourceValidation)
@@ -179,7 +179,7 @@ class CaffeOnSpark(@transient val sc: SparkContext) extends Serializable {
179179
var trainDataRDD: RDD[T1] = source.makeRDD(sc)
180180
if (trainDataRDD == null) {
181181
log.info("No training data is given")
182-
return
182+
throw new IllegalStateException("No training data is given")
183183
}
184184

185185
setupTraining(Array(source))
@@ -255,13 +255,13 @@ class CaffeOnSpark(@transient val sc: SparkContext) extends Serializable {
255255
var trainDataRDD: RDD[T1] = sourceTrain.makeRDD(sc)
256256
if (trainDataRDD == null) {
257257
log.info("No training data given")
258-
return null
258+
throw new IllegalStateException("No training data given")
259259
}
260260

261261
var validationDataRDD: RDD[T1] = sourceValidation.makeRDD(sc)
262262
if (validationDataRDD == null) {
263263
log.info("No validation data given")
264-
return null
264+
throw new IllegalStateException("No validation data given")
265265
}
266266

267267
val conf = sourceTrain.conf
@@ -273,7 +273,7 @@ class CaffeOnSpark(@transient val sc: SparkContext) extends Serializable {
273273
log.info("no_of_records_required_per_partition_train: " + no_of_records_required_per_partition_train)
274274
if (total_records_train < no_of_records_required_per_partition_train * conf.clusterSize) {
275275
log.error("Train data is insufficient for the hyperparameters configured. Adjust the train hyperparameters or increase the training data!")
276-
return null
276+
throw new IllegalStateException("Train data is insufficient for the hyperparameters configured. Adjust the train hyperparameters or increase the training data!")
277277
}
278278

279279
val no_of_records_required_per_partition_validation = conf.solverParameter.getTestIter(0) * sourceValidation.batchSize()
@@ -282,7 +282,7 @@ class CaffeOnSpark(@transient val sc: SparkContext) extends Serializable {
282282
log.info("no_of_records_required_per_partition_validation: " + no_of_records_required_per_partition_validation)
283283
if (total_records_validation < no_of_records_required_per_partition_validation * conf.clusterSize) {
284284
log.error("Validation data is insufficient for the hyperparameters configured. Adjust the validation hyperparameters or increase the validation data!")
285-
return null
285+
throw new IllegalStateException("Validation data is insufficient for the hyperparameters configured. Adjust the validation hyperparameters or increase the validation data!")
286286
}
287287

288288
val validationOutputBlobNames = setupTraining(Array(sourceTrain, sourceValidation))

0 commit comments

Comments
 (0)