TENSORFLOW1.0运行之前版本代码报错解决

1报错位置:.tf.scalar_summary('batch_loss', loss)AttributeError: 'module' object has no attribute 'scalar_summary'修改为:tf.summary.scalar('batch_loss', loss)原因:新版本做了调整

2.AttributeError: 'module' object has no attribute 'histogram_summary'修改为:tf.summary.histogram

3.tf.merge_all_summaries()改为:summary_op = tf.summaries.merge_all()

4.AttributeError: 'module' object has no attribute 'SummaryWriter':tf.train.SummaryWriter改为tf.summary.FileWriter

报错解决

12-23

//#include rn//Define _WIN32_WINNT 0x0500rnrn#define MAX_LOADSTRING 1000rnrnrn#include "resource.h"rn#include rnrn//#include rnrn//HANDLE hInst; // current instance rnHINSTANCE hInst;rnint APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow); rnLRESULT CALLBACK Mydialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);rnLRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);rnLRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); rn int __stdcall MyRegisterClass(HINSTANCE); rnBOOL __stdcall InitInstance(HINSTANCE hInstance, int nCmdShow ); rnrn//int __stdcall rnint APIENTRY WinMain(HINSTANCE hInstance, rn HINSTANCE hPrevInstance,rn LPSTR lpCmdLine,rn int nCmdShow )rn rnMSG msg;rnHACCEL hAccelTable;rnTCHAR szTitle[MAX_LOADSTRING];rnTCHAR szWindowClass[MAX_LOADSTRING];rnrn//初始化全局字符串rnLoadString(hInstance,IDS_APP_TITLE,szTitle,MAX_LOADSTRING);rnLoadString(hInstance,IDC_EXAM3_2, szWindowClass,MAX_LOADSTRING);rnMyRegisterClass(hInstance); rn//初始化应用程序rnif (!InitInstance (((hInstance ,nCmdShow)) //创建并显示窗口rn rn return FALSE;rnrnhAccelTable = LoadAccelerators(hInstance,(LPCTSTR)IDC_EXAM3_2); //装载加速键表rn//主消息循环rnwhile(GetMessage(&msg,(HWND) NULL,0,0))rnrn if(!TranslateAccelerator(msg.hwnd,hAccelTable,&msg))rn rn TranslateMessage(&msg);rn DispatchMessage(&msg);rn rnrnreturn msg.wParam;rnrnrnrnLRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)rnrnint wmId,wmEvent;rnPAINTSTRUCT ps;rnHDC hdc;rnTCHAR szHello[MAX_LOADSTRING];rnLoadString (hInst, IDS_HELLO,szHello, MAX_LOADSTRING);// hInstrn//分派消息处理rnswitch (message)rnrncase WM_COMMAND: //处理消息菜单 rn wmId = LOWORD(wParam);rn wmEvent = HIWORD(wParam);rn //PARSE the menu selectionsrn switch(wmId)rn rn case IDM_ABOUT:rn DialogBox(hInst,(LPCTSTR)IDD_ABOUTBOX,hWnd, (DLGPROC)About);rn break;rn case IDM_EXIT:rn DestroyWindow(hWnd);rn break;rn default:rn return DefWindowProc(hWnd,message,wParam,lParam);rn rn break;rncase WM_PAINT: //窗口重绘消息rn hdc = BeginPaint(hWnd,&ps);rn RECT rt;rn GetClientRect(hWnd, &rt);rn DrawText(hdc , szHello,strlen(szHello),&rt,DT_CENTER);rn EndPaint(hWnd, &ps);rn DrawText(hdc,"starting you vc++ leaging",28,&rt,DT_SINGLELINE|DT_CENTER|DT_VCENTER);rn break;rncase WM_DESTROY:rn PostQuitMessage(0);rn break;rndefault:rn return DefWindowProc(hWnd,message,wParam,lParam);rnrnreturn 0;rnrn//about 对话框消息处理函数rnLRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)rnrnswitch (message)rnrncase WM_INITDIALOG:rn return TRUE;rncase WM_COMMAND:rn if (LOWORD(wParam) == IDOK||LOWORD(wParam) ==IDCANCEL)rn rn EndDialog(hDlg,LOWORD(wParam));rn return TRUE;rn rn break;rnrn return FALSE;rnrnrn//****************************************rnLRESULT CALLBACK Mydialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)rnrnswitch(message)rnrncase WM_INITDIALOG:rn return TRUE;rncase WM_COMMAND:rn if(LOWORD(wParam) == IDOK || LOWORD(wParam)== IDCANCEL)rn rn EndDialog(hDlg,LOWORD(wParam));rn return TRUE; rn rn break;rnrnreturn FALSE;rnrnrnrnrnrnrnrn2.obj : error LNK2001: unresolved external symbol "int __stdcall InitInstance(struct HINSTANCE__ *,int)" (?InitInstance@@YGHPAUHINSTANCE__@@H@Z)rn2.obj : error LNK2001: unresolved external symbol "int __stdcall MyRegisterClass(struct HINSTANCE__ *)" (?MyRegisterClass@@YGHPAUHINSTANCE__@@@Z)rnDebug/3_2.exe : fatal error LNK1120: 2 unresolved externalsrnrn解决不了了,郁闷

没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试