Getting Started testing for Autokeras Windows

Source: Internet
Author: User

Tags: RAC technology share Image MIT TPs Verify eval tar print

In the test to analyze the effect of the IDE, in the Pycharm test when the teacher prompted memory overflow, and run Autokeras CNN really consumes a lot of space. But on the same computer, there is no problem when you change the Vscode for testing. I don't know what's going on. Recommended if the computer running memory is not 12G recommended don't run. It's a good idea to use Vscode. This IDE performs relatively efficiently. And there are few problems. The only certainty is that writing code is inefficient. You can also write code in Pycharm and put it in Vscode to perform the test.

Test data download Link: Https:// Password: 3UBR

Test code:

#Coding:utf-8Importosos.environ['Tf_cpp_min_log_level'] ='2'ImportNumPy as NPImportMatplotlib.pyplot as Plt fromScipy.miscImportimresizeImportCv2 fromAutokeras.image_supervisedImportImageclassifier fromSklearn.metricsImportAccuracy_score fromKeras.modelsImportLoad_model fromKeras.utilsImportPlot_modelImportTimestart=time.time ()defread_img (path,class_num): Imgname_list=os.listdir (path) n=Len (imgname_list)#img_index,img_colummns,img_rgbsize = plt.imread (path+ '/' +imgname_list[0]). ShapeImg_index, img_colummns = [28,38]#This setting is important. If your computer is good, you can ignore the settings. Otherwise, there is not enough memory.     Print(img_index,img_colummns) data= Np.zeros ([n,img_index,img_colummns,1]) Label= Np.zeros ([n,1]) Class_number=0 forIinchrange (N): Imgpath= path+'/'+Imgname_list[i] data[i,:,:,0]=imresize (Cv2.cvtcolor (Plt.imread (Imgpath), Cv2. Color_bgr2gray), [img_index,img_colummns])if(i)% (class_num) = =0:class_number= Class_number+1label[i,0]=Class_numberreturnData,labelx_train,y_train= Read_img ('./data/re/train', 80) X_test,y_test= Read_img ('./data/re/test', 20) Animal= ['Bus','Dinosaur','Flower','Horse','Elephant']#animal category corresponds to Labelvalue for [1,2,3,4,5]#plt.imshow (x_test[0,:,:,0],cmap= ' Gray ') ()if __name__=='__main__':    #Model BuildingModel = Imageclassifier (verbose=True)#Search Network (x_train,y_train,time_limit=1*60)    #Validate the optimal modelModel.final_fit (x_train,y_train,x_test,y_test,retrain=True)#give the results of the assessmentScore =model.evaluate (x_test,y_test)#Recognition ResultsY_predict =model.predict (x_test)#accuracyaccuracy =Accuracy_score (y_test,y_predict)#print out score and accuracy    Print('Score:', Score,'accuracy:', accuracy) Model_dir= R'./modelstructure/imgmodel.h5'model_img= R'./modelstructure/imgmodel_st.png'    #saving a visual model    #Model.load_searcher (). Load_best_model (). Produce_keras_model (). Save (Model_dir)    #Load Model    #Automodel = Load_model (model_dir)    #output model structure diagram    #Plot_model (Automodel, to_file=model_img)End=time.time ()Print(End-start)

Getting Started testing for Autokeras Windows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: