ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

2021年人工神经网络课程作业处理记录

2022-01-19 12:01:39  阅读:129  来源: 互联网

标签:inforsub return 作业处理 idstr ret 人工神经网络 2021 rowid hwstr



§01 业处理


在2021年秋季 人工神经网络 课程中,是由两个班级:

  • 清华大学校内课程;
  • 深圳研究院课程;

1.1 作业要求

全学期的作业总共有四次作业和一篇课程小论文。

1.1.1 四次作业要求

1.1.2 小论文要求

  • 作业题目: 期末小论文要求
  • 作业说明: 期末论文报告内容可以采用以下三种形式:
    • (1) 综述类型: 参照期刊或者会议论文中的综述类的文章,对于涉及到人工神经网络相关的某些理论发展方向、工程
      应用技术、新的算法模式等进行综述。建议所涉及到的参考论文不少于10篇。
    • (2) 工程应用类型:参照期刊或者会议论文的研究性论文,结合自己未来课题方向,应用神经网络相关算法,解决工
      程应用问题。可以包括工程应用,算法更新或者交叉学科应用等。
    • (3) 理论研究类型:可以针对人工神经网络算法所涉及到的算法理论相关的问题进行研究和讨论。比如对算法过程中的收敛问题、推广性的问题、训练算法中的超参调整问题的研究; 与其他优化方法、数值计算方法、机器学习方法相结合提出新的算法理论框架; 或者将现有的算法进行相互融合、深度改造形成有新特性的算法等。

其它要求参考课堂对于报告的要求讲解。


§02 业统计


在今天(2021-12-27)开始处理所有提交的四次作业,

下载与解压

作业下载

作业从网络学堂打包下载,两个班级的作业分别存储在:H:\Teaching\NN2021A中。

├─HWSZH
└─HWTSH

作业解压缩

下载所有作业文件以及很多提交的作业都是压缩文件。使用 Bandizip 解压缩软件将它们解压缩到各自的目录。

▲ 图1.1 自动加压缩到各自的目录


利用Bandizip加压缩软件,可以避免在以往使用winzip, winrar软件过程中碰到的格式错误问题。批量加压缩可以大大提高加压缩的效率。

▲ 图1.2 解压缩作业文件


下载成绩登记表格

从Infor中导出学生信息EXCEL表格。

▲ 图2.2.1 导出学生信息


设置学生信息的表头信息,具体信息如下所示。

▲ 图2.2.2 学生信息EXCEL表格表头


作业处理

根据 2020秋季人工神经网络作业登记与批改 处理方式,编写处理程序完成成绩的自动登录。

处理程序

#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# SETSCORE.PY                  -- by Dr. ZhuoQing 2021-01-02
#
# Note:
#============================================================

from head import *
import inforsub

#------------------------------------------------------------
def dropfile2studentid():
    tspdropfile2pastetext()
    pastestr = clipboard.paste()
    strsect = pastestr.split('\\')
    for s in strsect[-1:0:-1]:
        if s.count('_') >= 2:
            if s.split('_')[0].isdigit():
                return s.split('_')[0]
            if s.split('_')[0][0] == 'P':
                return s.split('_')[0]

    return "ERROR"

#------------------------------------------------------------
def setscore(idstr, hwstr, score):
    ret = inforsub.setexcelcellstring(inforsub.tshfile, idstr, hwstr, score)
    if ret >= 0: return 'TS',ret

    ret = inforsub.setexcelcellstring(inforsub.shzhfile, idstr, hwstr, score)
    if ret >= 0: return 'SHZH',ret

    return ' ', -1

#------------------------------------------------------------
def appendscore(idstr, hwstr, score):
    ret = inforsub.appendexcelcellstring(inforsub.tshfile, idstr, hwstr, score)
    if ret >= 0:
        return 'TS',ret

    ret = inforsub.appendexcelcellstring(inforsub.shzhfile, idstr, hwstr, score)
    if ret >= 0:
        return 'SHZH',ret

    return ' ', -1

def showscore(idstr):
    ret = inforsub.showexcelinfor(inforsub.tshfile, idstr)
    if ret >= 0: return 'TS', ret

    ret = inforsub.showexcelinfor(inforsub.shzhfile, idstr)
    if ret >=0: return 'SHZH', ret

    return ' ', -1

#------------------------------------------------------------
if __name__ == "__main__":
    idstr = dropfile2studentid()

    if idstr == 'ERROR':
        printf("No student id is found by drop file !\a")
        exit()

    printf('ID : %s\a'%idstr)

    #--------------------------------------------------------

    hwstr = ''
    scorestr = ''

    printf('Begin Modified:')
    x, y = showscore(idstr)
    printff(x,y)

    if len(sys.argv) > 1:
        hwstr = sys.argv[1]

        if hwstr in "hw1 hw2 hw3 hw4".split():
            hwstr = hwstr.upper()

        if hwstr in "1 2 3 4".split():
            hwstr = "HW%s"%hwstr

        if hwstr == 'note':
            hwstr = 'NOTE'
        if hwstr == 'n':
            hwstr = 'NOTE'

        if hwstr == 'paper':
            hwstr = 'PAPER'
        if hwstr == 'p':
            hwstr = 'PAPER'

        if not hwstr in 'HW1 HW2 HW3 HW4 PAPER NOTE'.split():
            printf('HW string error[%s].\a'%hwstr)
            exit()

    if len(sys.argv) > 2:
        scorestr = sys.argv[2]

    if len(hwstr) > 0:
        if hwstr == 'NOTE':
            appendscore(idstr, 'NOTE', scorestr)
        else: setscore(idstr, hwstr, scorestr)

    #--------------------------------------------------------
    printf("After Modified:")
    showscore(idstr)
    printf(' \a')

#------------------------------------------------------------
#        END OF FILE : SETSCORE.PY
#============================================================
#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# INFORSUB.PY                  -- by Dr. ZhuoQing 2020-06-18
#
# Note:
#============================================================

from headm import *                 # =
import pandas as pd

#------------------------------------------------------------
tshfile = tspstring2text('TSH')
shzhfile = tspstring2text('SHZH')

HOMEWORK_SHEET       = 'homework'

#------------------------------------------------------------
def showexcel(filename):
    excelfile = pd.read_excel(filename, sheet_name=HOMEWORK_SHEET)
    listdata = excelfile.values.tolist()

    for id,l in enumerate(listdata):
        printff(id, l)

def showexcelinfor(filename, sid):
    excelfile = pd.read_excel(filename, sheet_name=HOMEWORK_SHEET)

    rowid = -1
    for id, content in excelfile.items():
        if id == '学号':
            content = [str(s) for s in content]
            if str(sid) in content:
                rowid = content.index(str(sid))
            break

    if rowid < 0:
        return rowid

    printf(excelfile.values.tolist()[rowid])
    return rowid

#------------------------------------------------------------
def setexcelcellstring(filename, sid, col, num):
    excelfile = pd.read_excel(filename, sheet_name=HOMEWORK_SHEET)

    rowid = -1
    for id, content in excelfile.items():
        if id == '学号':
            content = [str(s) for s in content]
            if str(sid) in content:
                rowid = content.index(str(sid))
            break

    if rowid < 0:
        return rowid

    printff(rowid, col)

    excelfile[col] = excelfile[col].astype(str)
    excelfile.at[rowid, col] = num

    excelfile.to_excel(filename, sheet_name=HOMEWORK_SHEET, index=False)

    return rowid

#------------------------------------------------------------
def appendexcelcellstring(filename, sid, col, num):
    excelfile = pd.read_excel(filename, sheet_name=HOMEWORK_SHEET)

    rowid = -1
    for id, content in excelfile.items():
        if id == '学号':
            content = [str(s) for s in content]
            if str(sid) in content:
                rowid = content.index(str(sid))
            break

    if rowid < 0:
        return rowid

    printff(rowid, col)
    excelfile[col] = excelfile[col].astype(str)

    if excelfile.at[rowid, col] != 'nan':
        excelfile.at[rowid, col] = num + ', ' + excelfile.at[rowid, col]
    else: excelfile.at[rowid, col] = num

    if len(num) == 0: excelfile.at[rowid, col] = ''

    excelfile.to_excel(filename, sheet_name=HOMEWORK_SHEET, index=False)

    return rowid

#------------------------------------------------------------
def getexcelcellstring(filename, sid, col):
    excelfile = pd.read_excel(filename, sheet_name=HOMEWORK_SHEET)

    rowid = -1
    for id, content in excelfile.items():
        if id == '学号':
            content = [str(s) for s in content]
            if str(sid) in content:
                rowid = content.index(str(sid))
            break

    if rowid < 0:
        return rowid

#    printff(rowid, col)
#    excelfile[col] = excelfile[col].astype(str)
    return excelfile.at[rowid, col]

#------------------------------------------------------------
if __name__ == "__main__":
#    setexcelcellstring(tshfile, '2020210975', 'HW1', 88)
#    s = getexcelcellstring(tshfile, '2020210975', 'HW1')
#    printf(s)
#    showexcel(shzhfile)
    x=showexcelinfor(shzhfile, '2020280355')
    printf(x)

#------------------------------------------------------------
#        END OF FILE : INFORSUB.PY
#============================================================
#!/usr/local/bin/python
# -*- coding: gbk -*-
#============================================================
# SETALLSCORE.PY                     -- by Dr. ZhuoQing 2021-12-27
#
# Note:
#============================================================

from headm import *                 # =

#------------------------------------------------------------
import inforsub

#------------------------------------------------------------
def dropfile2studentid():
    tspdropfile2pastetext()
    pastestr = clipboard.paste()
    strsect = pastestr.split('\\')

    printf(strsect)

    for s in strsect[-1:0:-1]:
        if s.count('_') >= 1:
            if s.split('_')[0].isdigit():
                return s.split('_')[0]
            if s.split('_')[0][0] == 'P':
                return s.split('_')[0]

    return "ERROR"

#------------------------------------------------------------
def setscore(idstr, hwstr, score):
    ret = inforsub.setexcelcellstring(inforsub.tshfile, idstr, hwstr, score)
    if ret >= 0: return 'TS',ret

    ret = inforsub.setexcelcellstring(inforsub.shzhfile, idstr, hwstr, score)
    if ret >= 0: return 'SHZH',ret

    return ' ', -1

#------------------------------------------------------------
def appendscore(idstr, hwstr, score):
    ret = inforsub.appendexcelcellstring(inforsub.tshfile, idstr, hwstr, score)
    if ret >= 0:
        return 'TS',ret

    ret = inforsub.appendexcelcellstring(inforsub.shzhfile, idstr, hwstr, score)
    if ret >= 0:
        return 'SHZH',ret

    return ' ', -1

def showscore(idstr):
    ret = inforsub.showexcelinfor(inforsub.tshfile, idstr)
    if ret >= 0: return 'TS', ret

    ret = inforsub.showexcelinfor(inforsub.shzhfile, idstr)
    if ret >=0: return 'SHZH', ret

    return ' ', -1


#------------------------------------------------------------
tspdropfile2pastetext()
pastestr = clipboard.paste().split('\n')

#------------------------------------------------------------
id = []

for ps in pastestr:
    pss = ps.split('\\')[-1]
    pss = pss.split('_')[0]
    if len(pss) > 0:
        id.append(pss)

id = list(set(id))
printf(id, len(id))

#------------------------------------------------------------
if __name__ == "__main__":
    hwstr = ''
    scorestr = ''

    if len(sys.argv) < 3:
        printf("Usage: setallscore hw score\a")
        exit()

    #--------------------------------------------------------
    if len(sys.argv) > 1:
        hwstr = sys.argv[1]

        if hwstr in "hw1 hw2 hw3 hw4".split():
            hwstr = hwstr.upper()

        if hwstr in "1 2 3 4".split():
            hwstr = "HW%s"%hwstr

        if hwstr == 'note':
            hwstr = 'NOTE'
        if hwstr == 'n':
            hwstr = 'NOTE'

        if hwstr == 'paper':
            hwstr = 'PAPER'
        if hwstr == 'p':
            hwstr = 'PAPER'

        if not hwstr in 'HW1 HW2 HW3 HW4 PAPER NOTE'.split():
            printf('HW string error[%s].\a'%hwstr)
            exit()

    if len(sys.argv) > 2:
        scorestr = sys.argv[2]


    for idstr in id:
#        printf('Begin Modified:')
#        showscore(idstr)

        if len(hwstr) > 0:
            if hwstr == 'NOTE':
                appendscore(idstr, 'NOTE', scorestr)
            else: setscore(idstr, hwstr, scorestr)

#        printf("After Modified:")
#        showscore(idstr)


id = list(set(id))
printf(id, len(id))
printf('\a')

#------------------------------------------------------------
#        END OF FILE : SETALLSCORE.PY
#============================================================

标签:inforsub,return,作业处理,idstr,ret,人工神经网络,2021,rowid,hwstr
来源: https://blog.csdn.net/zhuoqingjoking97298/article/details/122577419

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有