当前位置: 首页 > 编程日记 > 正文

生成静态文件的新闻系统核心代码

在网上看了许多能生成静态页的新闻系统,但基于asp.net的系统极少,闲下时间来自己写了一个,发出来,大家一起研究,代码没做什么优化,只是实现了功能

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Configuration;

namespace makehtmlfile
{
 /// <summary>
 /// makeallfiles 的摘要说明。
 /// </summary>
 public class makeallfiles : System.Web.UI.Page
 {
  public string strcon;
  public OleDbConnection conn;
  public string strSQL;

private void Page_Load(object sender, System.EventArgs e)
  {
   
   InitialPages();// 在此处放置用户代码以初始化页面
  }

public void InitialPages()
  {
   strcon    = "provider=Microsoft.jet.OLEDB.4.0;data Source="+Server.MapPath(ConfigurationSettings.AppSettings["MDBpath2"])+";";//连接字符窜// 在此处放置用户代码以初始化页面
            strSQL = "select id,class1id,class2id from news order by id desc";
   MakeAreaForShow();
   ReadNewsForWriteFileUserDataReader();      //同过DataReader来读取数据,
   //ReadNewsForWriteFileUserDataSet();      //将数据直接挂入DataSet中来读取,
  }
  /// <summary>
  /// 用来产生循环显示页面的区域,装载生成HTML页的ASPX页面的区域
  /// </summary>
  public void MakeAreaForShow()
  {
   Response.Write("<span id=showImport></span>");
   Response.Write("<IE:Download ID='oDownload' STYLE='behavior:url(#default#download)'/>");
  }

/// <summary>
  /// 通过DATAREADER来读取数据
  /// </summary>
  public void ReadNewsForWriteFileUserDataReader()
  {
   int              num        =   0   ;
   string           newsid     =   null;
   string           class1id   =   null;
   string           class2id   =   null;
   OleDbDataReader  dr         =   null;
   OleDbConnection  conn       =   new OleDbConnection(strcon);
   conn.Open();
   OleDbCommand     mycommand  =   new OleDbCommand(strSQL,conn);
   dr                          =   mycommand.ExecuteReader();
   while(dr.Read())
   {
    newsid                  =   dr["id"].ToString();
    class1id                =   dr["class1id"].ToString();
    class2id                =   dr["class2id"].ToString();
                WriteJScript(newsid,class1id,class2id);
    num++;
   }
   dr.Close();
   conn.Close();
   Response.Write(num.ToString());

}

/// <summary>
  /// 通过DATASET来读取数据
  /// </summary>
  public void ReadNewsForWriteFileUserDataSet()
  {
   DataSet          ds         =   new DataSet();
   int              num        =   0   ;
   string           newsid     =   null;
   string           class1id   =   null;
   string           class2id   =   null;

OleDbConnection  conn       =   new OleDbConnection(strcon);
   conn.Open();
   OleDbDataAdapter da         =   new OleDbDataAdapter(strSQL,conn);
   da.Fill(ds,"news");
   conn.Close();
   num                         =   ds.Tables["news"].Rows.Count;
   foreach(DataRow dr in ds.Tables["news"].Rows)
   {
    newsid     =    dr["id"].ToString();
    class1id   =    dr["class1id"].ToString();
    class2id   =    dr["class2id"].ToString();
    WriteJScript(newsid,class1id,class2id);
   }
   ds = null;
   Response.Write(num.ToString());
   
  }

public void WriteJScript(string newsid,string class1id,string class2id)
  {
   Response.Write("<script>");
   Response.Write("function onDownloadDone(downDate)");
   Response.Write("{");
   Response.Write("showImport.innerHTML=downDate");
   Response.Write("}");
   Response.Write("oDownload.startDownload('makefile2.aspx?id=");
   Response.Write(newsid);
   Response.Write("&class1id=");
   Response.Write(class1id);
   Response.Write("&class2id=");
   Response.Write(class2id);
   Response.Write("',onDownloadDone)");
   Response.Write("</script>");
  }

#region Web 窗体设计器生成的代码
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {   
   this.Load += new System.EventHandler(this.Page_Load);

}
  #endregion
 }
}

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Configuration;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.IO;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace makehtmlfile
{
 /// <summary>
 /// makefile2 的摘要说明。
 /// </summary>
 public class makefile2 : System.Web.UI.Page
 {
  public string strcon;
  public OleDbConnection conn;
  
  public string class1id;
  public string class2id;
  //***********************************
  public string previd;
  public string prevtitle;
  public string nextid;
  public string nexttitle;
  //***********************************
  public string newstitle;
  public string newscontent;
  public string newsdate;
  public string newsip;
  public string newsid;
  //************************************

private void Page_Load(object sender, System.EventArgs e)
  {
   strcon    = "provider=Microsoft.jet.OLEDB.4.0;data Source="+Server.MapPath(ConfigurationSettings.AppSettings["MDBpath2"])+";";//连接字符窜// 在此处放置用户代码以初始化页面
   if(Request.Params["id"]!=null&&Request.Params["class1id"]!=null&&Request.Params["class2id"]!=null)
   {
    InitialPages();

}// 在此处放置用户代码以初始化页面
  }

public void InitialPages()
  {
   strcon    = "provider=Microsoft.jet.OLEDB.4.0;data Source="+Server.MapPath(ConfigurationSettings.AppSettings["MDBpath2"])+";";
   
   if(Request.Params["id"]!=null)
   {
    newsid  = Request.Params["id"].ToString();
   }
   if(Request.Params["class1id"]!=null)
   {
    class1id  = Request.Params["class1id"].ToString();
   }
   if(Request.Params["class2id"]!=null)
   {
    class2id  = Request.Params["class2id"].ToString();
   }
   ReadDataBase(newsid,class2id);
   MakeHtmlFile(newsid,class1id,class2id);
  }

/// <summary>
  /// 读写同一分类中,上一篇,和下一篇文章
  /// </summary>
  /// <param name="inputid"> 该文章ID</param>
  /// <param name="class2id">该文章所属分类ID</param>
  public void ReadPrevAndNext(string inputid,string class2id)
  {
   int               id                 =    int.Parse(inputid);
   string            strPrevSQL         =    "select top 1 id,newstitle,newsdate from news where class2id='"+ class2id +"' and id<"+id+" order by id desc";
   string            strNextSQL         =    "select top 1 id,newstitle,newsdate from news where class2id='"+ class2id +"' and id>"+id+" order by id asc";
   OleDbDataReader   datar              =    null;
   OleDbConnection con       = new OleDbConnection(strcon);
   con.Open();
   OleDbCommand newcommand   = new OleDbCommand(strPrevSQL,con);
   datar                     = newcommand.ExecuteReader();
   while(datar.Read())
   {
    previd    =  datar["id"].ToString();
    prevtitle =  datar["newstitle"].ToString();
   }
   datar.Close();
   newcommand.CommandText = strNextSQL ;
   datar                  = newcommand.ExecuteReader();
   while(datar.Read())
   {
    nextid     =  datar["id"].ToString();
    nexttitle  =  datar["newstitle"].ToString();
   }
   con.Close();

}

/// <summary>
  /// 将文章信息从库中读出,并将准备生成的HTML文件路径写入库中
  /// </summary>
  /// <param name="inputid"></param>
  /// <param name="class2id"></param>
  public void ReadDataBase(string inputid,string class2id)
  {
   string filename_w = MakeFileName(class1id,class2id,newsid)+".htm";
   
   ReadPrevAndNext(inputid,class2id);       //读取下一篇和上一篇的信息。


   OleDbConnection mycon  = new OleDbConnection(strcon);          //打开数据库连接
   mycon.Open();

int              id    = int.Parse(inputid);
   string       strSQL    = "select * from news where id="+id;
   OleDbDataReader  dr    = null;
   OleDbCommand mycommand = new OleDbCommand(strSQL,mycon);
   dr                     = mycommand.ExecuteReader();
   while(dr.Read())
   {
    newstitle   = dr["newstitle"].ToString();
    newscontent = dr["newscontent"].ToString();
    newsdate    = dr["newsdate"].ToString();
    newsip      = dr["newsip"].ToString();
   }
   dr.Close();
   mycommand.CommandText = "update news set url='"+ filename_w +"' where id="+int.Parse(inputid);   //将生成的文件路径写入库中,以遍在生成分类页中方便使用
   mycommand.ExecuteNonQuery();
   mycon.Close();
   
  }


  /// <summary>
  /// 生成目标目录和文件,主要用来生成不同分类的目录
  /// </summary>
  /// <param name="inputstr"></param>
  /// <returns></returns>
  public string MakeCatalogName(string class1,string class2)            //生成目标目录文件
  {
   string namestr   = "Article";
   string rootstr   = Server.MapPath(".").ToString();
   string class1str  = rootstr + "//" + namestr + "_" + class1 + "//";
   string class2str  = rootstr + "//" + namestr + "_" + class1 + "//" + namestr + "_" + class2 + "//";
   if(!Directory.Exists(class1str))
   {
    Directory.CreateDirectory(class1str);
   }
   if(!Directory.Exists(class2str))
   {
    Directory.CreateDirectory(class2str);
   }
              //创建目标文件夹
   return class2str;
  }

/// <summary>
  /// 根据文章分类和ID生成文件名
  /// </summary>
  /// <param name="class1id"></param>
  /// <param name="class2id"></param>
  /// <param name="nid"></param>
  /// <returns>返回文件名</returns>
  public string MakeFileName(string class1,string class2,string id)    //生成文件名,能够生成上下篇
  {
   string myclass2id    = class2;
   string myclass1id    = class1;
   string s             = DateTime.Now.Year.ToString()
    +DateTime.Now.Month.ToString()
    +DateTime.Now.Day.ToString()
    +"_"
    +myclass1id 
    +"_"
    +myclass2id                         //父类ID
    +"_"
    +id;                               //新闻ID
   return s;
  }

/// <summary>
  /// 生成HTML文件
  /// </summary>
  /// <param name="nid">文章ID号</param>
  public void MakeHtmlFile(string nid,string cla1id,string cla2id)                      //  MakeHtmlFile(string nid,string cla1id,string cla2id,string filetemp)  用于区分不同的摸班
  {
   string file_path            =   Server.MapPath ("template/news_mb.htm");
   string desfilename          =   MakeFileName(cla1id,cla2id,nid)+".htm";
   string desfile              =   MakeCatalogName(cla1id,cla2id)+MakeFileName(cla1id,cla2id,nid)+".htm";
   string prevurl              =   MakeFileName(cla1id,cla2id,previd)+".htm";                 //根据分类和ID生成上下篇的文件连接名
   string nexturl              =   MakeFileName(cla1id,cla2id,nextid)+".htm";                 //下篇
   System.Text.Encoding code   =   System.Text.Encoding.GetEncoding("gb2312");
  
   StreamReader srd            =   null;        //读
   StreamWriter swr            =   null;        //写
  
   string strFile              =   null ;       //字符串
  
   try
   {
    srd                     =   new StreamReader(file_path, code);
    strFile                 =   srd.ReadToEnd(); // 读取文件
   }
   catch(Exception exp)
   {
    HttpContext.Current.Response.Write(exp.Message);
    HttpContext.Current.Response.End();
    srd.Close();
   }
  
   strFile = strFile.Replace("$title$",newstitle);
   strFile = strFile.Replace("$content$",newscontent);
   strFile = strFile.Replace("$date$",newsdate);
   strFile = strFile.Replace("$ip$",newsip);
   strFile = strFile.Replace("$prev$",prevtitle);
   strFile = strFile.Replace("$next$",nexttitle);
   strFile = strFile.Replace("$prevurl$",prevurl);
   strFile = strFile.Replace("$nexturl$",nexturl);
 
   try
   {
    swr = new StreamWriter(desfile,false,code);
    swr.Write(strFile);
    swr.Flush();
   }
   catch(Exception ex)
   {
    HttpContext.Current.Response.Write(ex.Message);
    HttpContext.Current.Response.End();
   }
   finally
   {
    swr.Close();
   }
   if(srd!=null)
   {
    srd.Close();
   }
   Response.Write(desfilename);

}

public void Open()
  {
   if(conn==null)
   {
    conn = new OleDbConnection(strcon);
    conn.Open();
   }
  }
  public void Close()
  {
   if(conn!=null)
   {
    conn.Close();
   }
  }

#region Web 窗体设计器生成的代码
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {   
   this.Load += new System.EventHandler(this.Page_Load);
  }
  #endregion
 }
}


相关文章:

「软件」2.0时代已经到来,你需要这样的开发工具

互联网催生了软件的繁荣&#xff0c;而在AI浪潮的推动下&#xff0c;软件正在朝着更「智能」的方向发展&#xff0c;也就是「软件2.0」时代。「软件2.0」其实就是神经网络&#xff0c;也就是这一波AI浪潮的基石。 在「软件1.0」时代&#xff0c;程序员用Java、Python、C等语言…

WF4 Beta,RC版文章总结

Visual Studio 2010明天就要发布正式版了&#xff0c;伴随Visual Studio 2010的发布微软的新一代工作流框架Workflow Foundation 4也会正式发布。从Beta版开始就断断续续的开始关注了&#xff0c;并写了一些文章&#xff0c;今天总结下&#xff1a; WF4 Beta1的几篇文章&#x…

亚马逊云科技在中国区域上线机器学习新服务,打造广泛而深入的人工智能与机器学习工具集

2021年5月11日&#xff0c;在完全托管的机器学习服务Amazon SageMaker落地中国区域一周年之际&#xff0c;亚马逊云科技宣布通过与光环新网和西云数据的紧密合作在中国区域进一步落地多项人工智能与机器学习的新服务和功能&#xff0c;丰富了其针对不同企业需求而打造的人工智能…

mysql ERROR 1045

2019独角兽企业重金招聘Python工程师标准>>> C:\Program Files\MySQL\MySQL Server 5.0\bin> mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for user rootlocalhost (using password: YES) 编辑mysql配置文件my.ini&#xff08;不知道在…

C#:将另一个应用程序的主窗口移至屏幕最前

2019独角兽企业重金招聘Python工程师标准>>> 使用WindowsAPI函数SwitchToThisWindow&#xff0c;可以将指定窗口移动到屏幕最前。 如果要将另一个应用程序的窗口移动到最前&#xff0c;只需要找到该窗口的句柄&#xff0c;再调用SwitchToThisWindow函数即可。可通过…

阿里技术文档:Redis+Nginx+Spring全家桶+Dubbo精选

最近花了很长的时间去搜罗整理Java核心技术好文&#xff0c;我把每个Java核心技术的优选文章都整理成了一个又一个的文档。今天就把这些东西分享给老铁们&#xff0c;也能为老铁们省去不少麻烦&#xff0c;想学什么技能了&#xff0c;遇到哪方面的问题了 直接打开文档学一学就好…

网页刷新方法集合

代码如下&#xff1a; <input typebutton value刷新 οnclick"history.go(0)"> 代码如下&#xff1a; <input typebutton value刷新 οnclick"location.reload()"> 代码如下&#xff1a; <input typebutton value刷新 οnclick"…

MOS管体二极管的作用

这里有两种解释&#xff1a; 1、mos管本身自带有寄生二极管&#xff0c;作用是防止VDD过压的情况下&#xff0c;烧坏mos管&#xff0c;因为在过压对MOS管造成破坏之前&#xff0c;二极管先反向击穿&#xff0c;将大电流直接到地&#xff0c;从而避免MOS管被烧坏。 2、防止管子的…

Complex Instance Placement

转自&#xff1a; https://specs.openstack.org/openstack/openstack-user-stories/user-stories/proposed/complex-instance-placement.html This work is licensed under a Creative Commons Attribution 3.0 Unported License.http://creativecommons.org/licenses/by/3.0/…

在SecureCRT下使用sz下载和rz上传文件

之前通过FTP来下载Linux机器上的文件&#xff0c;在Windows编辑完后再上传&#xff0c;如此比较麻烦&#xff0c;刚听同事说用sz和rz命令可以实现在SecureCRT中上传下载。 配置上传下载目录&#xff1a;选择某个session 标签&#xff0c;点鼠标右键&#xff0c;弹出菜单…

开源的 6 条社会契约

作者 | Brett Cannon 译者 | 弯月 责编 | 欧阳姝黎出品 | CSDN&#xff08;ID&#xff1a;CSDNnews&#xff09;以下为译文&#xff1a;本文探讨一下关于开源用户权利的问题。我想指出一点&#xff0c;开源维护者不欠用户什么&#xff0c;而粗鲁地对待他们是一种不道德的行为…

理解linux tr命令

2019独角兽企业重金招聘Python工程师标准>>> 1. tr 命令的功能 tr命名是简化了的sed命令。其主要的功能包括&#xff1a; a. 用一个字符来替换另外一个字符。 b. 删除字符串中的指定子串。 c. 合并字符串中重复串。 2. 常见的命令格式&#xff1a; tr -c -d -s [&qu…

Lambda中的常用sql方法

1、Groupby 对集合进行分组&#xff0c;如&#xff1a; var dllList _menuMan.Load(c > c.TXT_ASSEMBLYNAME ! null).GroupBy(c>c.TXT_ASSEMBLYNAME).OrderByDescending(c>c.Count()).Select(c>c.Key).ToList(); 这里Goupby后面的OrderByDescending表示对每组数量…

刚发现的 Wi-Fi 安全漏洞,可能危及全球所有设备!

作者 | Carol出品 | CSDN&#xff08;ID&#xff1a;CSDNnews&#xff09;近日&#xff0c;纽约大学阿布扎比分校的安全研究员 Mathy Vanhoef &#xff08;马蒂范霍夫&#xff09;发现了一组可能会影响到数百万设备的 Wi-Fi漏洞。可怕的是&#xff0c;其中部分漏洞甚至可以追溯…

linux + ffmpeg + eclipse 调试

使用linux ffmpeg eclipse调试步骤OS : ubuntu 12.04Eclipse : 3.7.2 为Eclipse安装cdt插件&#xff0c;使其支持c/c导入ffmpeg项目File —-> Import —-> c / c —-> Existing Code as Makefile Project 输入 Project Name, 选择ffmpeg所在目录, Toolchain选择Linu…

在ASP.NET 2.0中使用样式、主题和皮肤

ASP.NET 2.0的主题和皮肤特性使你能够把样式和布局信息存放到一组独立的文件中&#xff0c;总称为主题&#xff08;Theme&#xff09;。接下来我们可以把这个主题应用到任何站点&#xff0c;用于改变该站点内的页面和控件的外观和感觉。通过改变主题的内容&#xff0c;而不用改…

C# 引用类型和值类型

1、引用类型 FCL(Framework)中的大多数类型都是引用类型,引用类型总是在托管堆中分配的,C#的new操作符会返回对象的内存地址,也就是指对象数据的内存地址。在使用引用类型时,存在以下性能问题,这是我们在开发中必须要注意的: a、内存必须从托管堆上分配(也就是说每new一个对象,…

dom4j读写xml文件

dom4j读写xml文件首先我们给出一段示例程序&#xff1a;import java.io.File;import java.io.FileWriter;import java.util.Iterator;import org.dom4j.Document;import org.dom4j.DocumentHelper;import org.dom4j.Element;import org.dom4j.io.OutputFormat;import org.dom4j…

图片、文件防盗链

关于图片盗链这个问题&#xff0c;毕竟是自己的劳动成功&#xff0c;很多人不希望别人就那么轻易地偷走了。 这个功能在很多的论坛上都具有&#xff0c;可能是因为盗链的行为太多了吧反盗链的程序其实很简单&#xff0c;熟悉ASP.NET 应用程序生命周期的话很容易就可以写一个&am…

脚本征集大赛开启啦!100%有奖!

对一个程序爱好者来说&#xff0c;最酷的事情莫非就是用你喜欢的语言一步步实现你的idea&#xff0c; 现在用 CSDN 浏览器助手插件&#xff0c; 不仅能提升浏览器效率&#xff0c;还能在上面开发黑科技脚本&#xff0c;帮助你实现各种 idea~

深入理解javascript中的立即执行函数(function(){…})()

2019独角兽企业重金招聘Python工程师标准>>> javascript和其他编程语言相比比较随意&#xff0c;所以javascript代码中充满各种奇葩的写法&#xff0c;有时雾里看花&#xff0c;当然&#xff0c;能理解各型各色的写法也是对javascript语言特性更进一步的深入理解。 …

Javascript学习7 - 脚本化浏览器窗口

原文:Javascript学习7 - 脚本化浏览器窗口本节讨论了文档对象模型、客户端Javascript下Window中的各项属性&#xff0c;包括计时器、Location对象、Histroy对象、窗口、浏览器等相关属性的讨论。 具体详细Window属性介绍可以参见&#xff1a;http://www.w3school.com.cn/htm…

ASP.Net 2.0 发送邮件的代码

这两天因为要做一个可以收集用户提交信息&#xff0c;然后发送邮件到指定邮箱的网页。在 asp.net 2.0 里面发送邮件可以使用 System.Net.Mail 下面的类。http://www.systemnetmail.com/faq/2.1.aspx 这个地址有 System.Net.Mail 的作者写的仿佛是 MSDN 类似的 Faq&#xff0c;看…

腾讯To B业务架构再升级,汤道生任云与智慧产业事业群CEO

5月14日&#xff0c;腾讯云与智慧产业事业群&#xff08;CSIG&#xff09;宣布新一轮架构升级&#xff0c;这是继2018年“930变革”后&#xff0c;腾讯To B业务的又一次重大进化。 在本轮战略升级中&#xff0c;腾讯公司高级执行副总裁汤道生担任云与智慧产业事业群CEO&#x…

一篇文章读懂阿里云负载均衡性能保障型实例

1. 什么是负载均衡性能保障型实例?2. 性能保障型实例如何收费&#xff1f;3. 性能保障型实例规格费的定价4. 如何选择性能保障型实例&#xff1f;5. 性能保障型实例的变配操作限制6. 性能保障型实例何时收费&#xff1f;7. 收费后性能共享型实例会收费吗&#xff1f;8. 为何有…

POJ 2135 Farm Tour 最小费用流

两条路不能有重边&#xff0c;既每条边的容量是1。求流量为2的最小费用即可。 //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #include<iostre…

Linux动态库和静态库比较

Linux动态库和静态库比较文件预览 文件目录树如下&#xff0c;如你所见&#xff0c;非常简单。 1. libtest/ 2. |-- lt.c 3. |-- lt.h 4. -- test.c #lt.c 1. 4. 5. #include 6. 7. void myprint(void) 8. { 9. printf("Linux librar…

“一键”部署分布式训练,微软“群策MARO”上新集群管理助手

作者 | 李开琪、王金予 编者按&#xff1a;2020年&#xff0c;微软亚洲研究院发布并开源了多智能体资源优化平台“群策MARO”。为了帮助不同需求的用户进行更加便捷、高效的集群管理&#xff0c;也希望用户可以方便快捷地部署分布式训练任务&#xff0c;微软亚洲研究院的研究员…

1968年12月9日,恩格尔巴特公开演示了世界上第一个鼠标盒子

鼠标之父”道格拉斯恩格尔巴特 腾讯科技讯&#xff0c;肖华2013年12月19日编译 计算机的几次革命和大规模普及都是始于人机交互的改变&#xff0c;今年7月2日&#xff0c;“鼠标之父”道格拉斯恩格尔巴特溘然辞世。人们才发现&#xff0c;他的发明远不止鼠标。作为人机交互的先…

GPT-3模型为何难以复现?这也许是分布式AI框架的最优设计

作者 | 成诚头图 | 下载于视觉中国2020 年&#xff0c;最轰动的 AI 新闻莫过于 OpenAI 发布的 GPT-3 了。它的1750亿参数量及其在众多NLP任务上超过人类的出众表现让大家坚信&#xff1a;大模型才是未来。但与之带来的问题是&#xff0c;训练超大模型所需的算力、存储已不再是单…