Beispiel #1
0
				transfer_model=transfer_learning.build_transfer_model(base_model)

				if(tl_type=='full_fine_tune'):
					model=transfer_learning.full_fine_tune(transfer_model)

				if(tl_type=='variable_lr'):
					model=transfer_learning.set_variable_learning_rates(transfer_model,conv_layer_m,dense_layer_m)

				if(tl_type=='feature_extractor'):
					model=transfer_learning.set_fixed_train_params(transfer_model)
		
			print('Model summary used for training')
			print(model.summary())
			
			train_model=TrainModel(batch_size,epocs,split_ratio)
			trained_model,eval_metrics,accuracy_metrics_df=train_model.run_train_model(model,combined_conv_data,combined_kcc_data,model_path,logs_path,plots_path,activate_tensorboard,run_id)

		print('Training complete for run: ',i)

		print('Print inferencing from trained model...')
		
		if(model_type=='Bayesian 3D Convolution Neural Network'):
			
			from bayes_model_deployment import BayesDeployModel
			#from tf.keras import backend as K
			
			deploy_model=BayesDeployModel()
			dl_model=Bayes_DLModel(model_type,output_dimension,optimizer,loss_func,regularizer_coeff,output_type)
			
			model=dl_model.bayes_cnn_model_3d(voxel_dim,voxel_channels)
			if(tl_type=='full_fine_tune'):
				model=transfer_learning.full_fine_tune(transfer_model)

			if(tl_type=='variable_lr'):
				model=transfer_learning.set_variable_learning_rates(transfer_model,conv_layer_m,dense_layer_m)

			if(tl_type=='feature_extractor'):
				model=transfer_learning.set_fixed_train_params(transfer_model)

		print(model.summary())

		print("Conducting data study study on :",train_dim, " samples")
		input_conv_subset=input_conv_data[0:train_dim,:,:,:,:]
		kcc_subset=kcc_subset_dump[0:train_dim,:]

		train_model=TrainModel(batch_size,epocs,split_ratio)
		trained_model,eval_metrics,accuracy_metrics_df=train_model.run_train_model(model,input_conv_subset,kcc_subset,model_path,logs_path,plots_path,activate_tensorboard,run_id)

		datastudy_output[i,0]=train_dim
		datastudy_output[i,1:assembly_kccs+1]=eval_metrics["Mean Absolute Error"]
		datastudy_output[i,assembly_kccs+1:(2*assembly_kccs)+1]=eval_metrics["Mean Squared Error"]
		datastudy_output[i,(2*assembly_kccs)+1:(3*assembly_kccs)+1]=eval_metrics["Root Mean Squared Error"]
		datastudy_output[i,(3*assembly_kccs)+1:(4*assembly_kccs)+1]=eval_metrics["R Squared"]

		file_name='metrics_data_study_'+str(train_dim)+'_.csv'
		accuracy_metrics_df.to_csv(logs_path+'/'+file_name)
		print("Model Training Complete on samples :",train_dim)
		print("The Model Validation Metrics are ")
		print(eval_metrics)

		#Inferring on test dataset
Beispiel #3
0
    #plot_model(base_model, to_file='model.png')

    transfer_model = transfer_learning.build_transfer_model(base_model)

    if (tl_type == 'full_fine_tune'):
        model = transfer_model

    if (tl_type == 'variable_lr'):
        model = transfer_learning.set_variable_learning_rates(
            transfer_model, conv_layer_m, dense_layer_m)

    if (tl_type == 'feature_extractor'):
        model = transfer_learning.set_fixed_train_params(transfer_model)

    train_model = TrainModel(batch_size, epocs, split_ratio)
    trained_model, eval_metrics, accuracy_metrics_df = train_model.run_train_model(
        model,
        input_conv_data[:, :, :, :, 1:2],
        kcc_subset_dump,
        model_path,
        logs_path,
        plots_path,
        activate_tensorboard,
        tl_type=tl_type)

    accuracy_metrics_df.to_csv(logs_path + '/tl_metrics.csv')
    print("Transfer Learning Based Model Training Complete..")
    print("The Model Validation Metrics are ")
    print(eval_metrics)