def test_get_block(): """Test get residual block.""" K.set_image_data_format('channels_last') Resnet3DBuilder.build((224, 224, 224, 1), 2, 'bottleneck', [2, 2, 2, 2], reg_factor=1e-4) assert True with pytest.raises(ValueError): Resnet3DBuilder.build((224, 224, 224, 1), 2, 'nullblock', [2, 2, 2, 2], reg_factor=1e-4)
## convert to 1 + 4D space (1st argument represents number of rows in the dataset) X_train = X_train.reshape(X_train.shape[0], 16, 16, 16, 1) X_test = X_test.reshape(X_test.shape[0], 16, 16, 16, 1) Y_train = to_categorical(Y_train, 10) Y_test = to_categorical(Y_test, 10) print("number of training examples = " + str(X_train.shape[0])) print("number of test examples = " + str(X_test.shape[0])) print("X_train shape: " + str(X_train.shape)) print("Y_train shape: " + str(Y_train.shape)) print("X_test shape: " + str(X_test.shape)) print("Y_test shape: " + str(Y_test.shape)) # model = Resnet3DBuilder.build_resnet_18((16, 16, 16, 1), 10) model = Resnet3DBuilder.build((16, 16, 16, 1), 10, basic_block, [1, 1, 1, 1], reg_factor=1e-4) adam = Adam(lr=0.0001) model.compile(optimizer=adam, loss='categorical_crossentropy', metrics=['accuracy']) earlystop = EarlyStopping(monitor='val_acc', min_delta=0.001, patience=5, verbose=2, restore_best_weights=True) callback_list = [earlystop] model_info = model.fit(X_train, Y_train, epochs=100,