【学习笔记】大模型实战-L02-Python

手写算法-python代码实现逻辑回归(带L1、L2正则项) 手写算法-python代码实现逻辑回归逻辑回归原理解析损失函数定义以及数学公式推导过程解释1:通俗易懂的手推损失函数:解释2:最大似然估计求解参数对损失函数推导梯度python代码实现逻辑回归 逻辑回归原理解析 前面我们系统性的介绍了线性回归,初学者建议把我前面的文章看完,再来看逻辑回归。写得应该算是容易看懂的了,且都有实例辅证,大家看的时候要自己跑一边代码,多动手、多思考。 今天,我们来讲逻辑回归。 逻辑回归是LogisticRegression的直译,它不是用来解决回归问题的,而是用来解决分类问题的,它 阅读详情

L02 Python

题目要求

一个wordcount函数,统计英文字符串中每个单词出现的次数。返回一个字典,key为单词,value为对应单词出现的次数。

代码实现

text = """
Got this panda plush toy for my daughter's birthday,
who loves it and takes it everywhere. It's soft and
super cute, and its face has a friendly look. It's
a bit small for what I paid though. I think there
might be other options that are bigger for the
same price. It arrived a day earlier than expected,
so I got to play with it myself before I gave it
to her.
"""

def wordcount(text):
    # 将文本按行分割
    lines = text.strip().split('\n')
    word_dict = {}
    
    # 遍历每一行
    for line in lines:
        # 将每行按空格分割成单词
        words = line.split()
        for word in words:
            # 将单词转换为小写
            word = word.lower()
            # 统计单词出现次数
            if word in word_dict:
                word_dict[word] += 1
            else:
                word_dict[word] = 1
    
    return word_dict

# 测试函数
input_text = """Hello world!  
This is an example.  
Word count is fun.  
Is it fun to count words?  
Yes, it is fun!"""

print(wordcount(input_text))

远程调试

使用本地vscode连接远程开发机,将上面代码在开发机上进行调试。
远程连接方法见前一篇笔记。

在这里插入图片描述

Reference

https://github.com/InternLM/Tutorial/blob/camp3/docs/L0/Python/task.md

【L0G2000】书生大模型第四期实战营第2关Python基础知识 本文将详细记录完成三个任务的全过程,包括编程技巧、工具使用以及问题解决思路。任务包括 Leetcode 问题解决、API 调试,以及 pip 安装到指定目录的实践。希望通过我的分享,能够帮助大家提升编程能力。完成 Leetcode 383 (“Ransom Note”),并提交代码,同时附上通过截图。题目要求通过判断字符串 中的所有字符是否都能在 中找到(且字符出现次数必须足够),来确定是否可以用 中的字符组成 。以下是解决方案代码: 测试与提交 测试用例 通过调试 OpenAI 接口代码,定 阅读详情

相关推荐

通俗易懂的L0范数和L1范数及其Python实现

L0 范数并不是真正意义上的一个范数,因为它不满足范数的三角不等式性质,但它在数学优化和信号处理等领域有着实际的应用。L0 范数指的是向量中非零元素的个数。它通常用来度量向量的稀疏性。数学上表示为:例如,向量 (x = [1, 0, 2, 0, 3]) 的 L0 范数是 3,因为该向量中有三个非零元素。

计算机视觉之光 2289

书生大模型实战营 L0 入门岛

书生大模型训练营入门岛任务——

volcan的博客 1276

STM32——IIC(I2C)中断与DMA通信实战解析

本文深入解析STM32的IIC(I2C)通信中断与DMA实战应用。通过对比轮询方式的低效,详细介绍中断模式和DMA模式的实现原理、状态机编程技巧及性能优化策略,并结合SHT30传感器案例展示如何高效读取数据,显著提升系统响应速度和CPU利用率。

week9的博客 808

02-Sentinel-2 L1C级数据bat和Python脚本批量大气校正

前言 大气校正方法 校正前后对比结果 参考文献

lidahuilidahui的博客 1万+

LightTools宏 vs Python API:光学仿真自动化方案选型指南

本文深入对比了LightTools光学仿真自动化中VBA宏与Python API两种方案。VBA宏内嵌易用,适合固定流程批处理;Python API生态强大,尤其在参数优化算法集成方面优势显著,便于构建复杂工作流。文章结合案例,为不同场景下的技术选型提供清晰指南。

garlic的博客 942

避坑指南:企业微信IP白名单设置失败的5种常见原因及解决方案

本文深入解析企业微信API调用中IP白名单设置失败的5种常见原因,包括动态公网IP变更、代理服务器导致的IP失真等,并提供针对性的解决方案。特别针对可信IP配置问题,详细介绍了诊断方法和Java代码示例,帮助企业开发者快速解决访问限制问题,确保API调用安全稳定。

weixin_29280657的博客 623

书生大模型实战(从入门到进阶)L0-Python

本文是对书生大模型L0-Python部分的学习和实现

m0_73672030的博客 1241

Maxwell涡流热损计算:铜导体在50Hz交流下的仿真实践

本文详细介绍了使用Maxwell软件进行铜导体在50Hz交流条件下的涡流热损仿真实践。从涡流热损的基本概念到Maxwell仿真设置、网格划分、结果后处理等关键步骤,提供了实用技巧和常见问题解决方案,帮助工程师准确计算涡流热损,优化电力设备设计。

weixin_42526015的博客 391

书生大模型实战(从入门到进阶)L0-Git

本文是对书生大模型L0-Git部分的学习和实现

m0_73672030的博客 693

ICC2 实战秘籍:create_workspace 命令全解析

必选项:工作区名称,这可是创建工作区的 “身份证”,必不可少。技术数据选项匹配:优先考虑用 -technology 直接加载技术文件,这是获取最新、最准确技术数据的首选路径;要是已经有合适的技术库了,那 -use_technology_lib 引用现有技术库也能快速上手。精度设置优先规则:技术文件自动配置排在第一位,能自动适配就别手动操心;要是自动配置不理想,那就显式指定 scale_factor;实在没要求,就用默认配置,但得清楚它的精度限制。

weixin_50820814的博客 1126

【ShaderToy】开篇

写在前面呜呼,好久没有写博客了,好惭愧。题外话,感觉越大就越想家,希望可以一直和家人在一起,哪怕只是坐在一起不说话也觉得很温暖,一想到要分开眼睛就开始酸,哎。开学还是爬上来老实更新博客学习吧~今天爬上来一看,发现优快云的博客编辑终于更新了!进步总是好的,以前的编辑器实在很捉急。使用这种标记语言的确方便了很多,但好像颜色字体没法设置?程序员果然对美观没什么追求。ShaderToy如果你还没听过Sha

candycat 8万+

L0G2000 Python 基础知识 书生大模型实战营

这节内容主要是两个部分,1个是熟悉远程编程环境如完成leetcode上的习题相关leetcode完成视图如下具体代码如下:else:else:注意leetcode有特殊环境,编程时需要注意。

tianxingzhe的博客 223

示波器学习(一):示波器的作用、类型和基本结构

示波器的作用、使用场景;示波器的类型和基本结构介绍

qq_41300605的博客 9142

【书生大模型实战营】Python 基础知识-L0G2000

本文是书生大模型实战营系列的第2篇文章,是入门岛的第二个任务,主题为:Python基础知识。

fzyz123的博客 760

合泰单片机HT32之keil5开发环境搭建(一)

1. 前言 这两天在准备合泰杯,但是总是感觉无从下手,因为合泰单片机的资料教程什么的非常少,不像stm32那样。而且听说要用合泰单片机的专用IDE,感觉当场被劝退了。后来经过查找资料,发现合泰单片机也有keil5的支持包,也就是说可以从库函数进行开发,不用从寄存器进行开发,但我找了好久,并没有找到教程,后来实在没办法,打算自己动手搭建环境,经过了大概两天的挣扎后,终于成功地搭建好了环境,也成功地点...

weixin_44713763的博客 8673

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

书生 共学大模型实战营第四期任务 L0-G200

⋅⋅。

Matrix_killer的博客 1273

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

L1和L2损失函数(L1 and L2 loss function)及python实现

       在我们做机器学习的时候,经常要选择损失函数,常见的损失函数有两种:L1-norm loss function和L2-norm loss function。       &

海军上将光之翼的博客 3万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

上海人工智能实验室·书生大模型实战营笔记(L0G1~G2)

书生大模型L0G1000~L0G2000的作业

Yalin_Coder的博客 1168

Camp4-L0:Python 前置基础

书生浦语大模型实战营第四期:python前置基础

fangsfdavid的博客 779

大模型微调实战全解:从理论到企业级实践(Python实战增强版)

大模型微调(Fine-tuning)是指在预训练语言模型(Pre-trained Language Model, PLM)的基础上,通过特定领域或任务的数据进一步调整模型参数,使其适应下游任务需求的技术。

HUANGXIN9898的博客 1256

Python入门到企业大模型实战:收藏这份系统学习指南,小白也能轻松掌握AI核心技能!

本文构建了企业大模型应用的完整知识框架,包含五个递进维度:Python编程基础(L1)、大模型核心原理与提示词工程(L2)、RAG构建企业知识库(L3)、Agent设计(L4)、大模型微调与部署(L5)。该体系从技术基础到业务落地,涵盖数据处理、模型优化、系统部署等全流程,强调实战应用与场景适配,帮助企业实现从技术选型到业务增值的完整闭环。每个模块均设置明确学习目标和实操内容,结合主流工具框架,兼顾理论深度与实践价值,助力企业高效构建专属AI能力。

Trb701012的博客 605

书生大模型实战营第4期——L0-Python

这题我的方法比较原始,就是计数。

Joe66693的博客 360

Python学习笔记Day02

Python学习笔记 Day 02 全栈开发课程共有90天左右,笔记记录老师上课所讲的要点以及课后作业及答案。 模块一Day01作业 T1: 作业内容:if条件 ##用户输入数字,比66大,则显示猜测结果大了,如果比66小,显示小了。 num=int(input('请输入一个整数:')) if num>66: print('大了') elif num<66: print...

IsTongtongah的博客 342

大模型微调技术全景解析:从理论到企业级实践(Python实战增强版)

大模型微调(Fine-tuning)是指在预训练语言模型(Pre-trained Language Model, PLM)的基础上,通过特定领域或任务的数据进一步调整模型参数,使其适应下游任务需求的技术。

Java癫疯的博客 1388

L0G2000书生大模型实战营第4期——1.2 Python简易示例和VSCode连接InternStudio debug

书生大模型实战营第4期即将在10月底开营。学习和实践在上海人工智能实验室提供的InternStudio开发机在线环境中完成。今天是第一阶段第二个任务,主要学习Python基础,完成简单的函数示例,并使用VSCode远程连接开发机进行Python debug。

wuzipl的博客 947
上一篇: 【学习笔记】大模型实战-L01-Linux
下一篇: 【学习笔记】昇思25天学习打卡(D15)CV06-Vision Transformer图像分类.ipynb
UnseenMe
博客等级 码龄20年 193粉丝 35原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值