if test[‘test_last‘] or test[‘test_best‘]:什么含义

 

test['test_last']是一种Python中字典数据类型的访问方式。在这种访问方式中,test是一个字典对象,'test_last'是该字典中的一个键(key),通过使用方括号[]将键包围起来,可以访问该键对应的值(value)。

例如,如果test是一个字典对象,其中包含键值对'test_last': True,那么test['test_last']将返回True同样,如果test['test_last']的值为False或任何其他可转换为布尔值的对象,条件表达式if test['test_last']将根据该值的真假进行判断。

 

 

这段代码使用 argparse 库添加了两个命令行参数:

  • --test-last: 该参数是一个布尔标志,用于指示是否在训练后测试检查点。当使用 --test-last 参数时,其值将被设置为 True
  • --test-best: 该参数也是一个布尔标志,用于指示是否在训练后测试最佳检查点(如果适用)。当使用 --test-best 参数时,其值将被设置为 True

这些命令行参数可以通过命令行界面传递给脚本,以控制是否进行训练后的测试操作。例如,可以使用以下命令启动脚本并设置相应参数:

 上述命令表示在训练后同时进行最后一个检查点和最佳检查点的测试。

也就是说if test['test_last'] or test['test_best']:这句话test['test_last']是True,而test['test_best']:也是True,于是if test['test_last'] or test['test_best']:整个就是True

在这种情况下,条件块中的代码将会执行

if test['test_last'] or test['test_best']:
        best_ckpt_path = None
        if test['test_best']:
            assert eval_hook is not None
            best_ckpt_path = None
            ckpt_paths = [x for x in os.listdir(cfg.work_dir) if 'best' in x]
            ckpt_paths = [x for x in ckpt_paths if x.endswith('.pth')]
            if len(ckpt_paths) == 0:
                logger.info('Warning: test_best set, but no ckpt found')
                test['test_best'] = False
                if not test['test_last']:
                    return
            elif len(ckpt_paths) > 1:
                epoch_ids = [
                    int(x.split('epoch_')[-1][:-4]) for x in ckpt_paths
                ]
                best_ckpt_path = ckpt_paths[np.argmax(epoch_ids)]
            else:
                best_ckpt_path = ckpt_paths[0]
            if best_ckpt_path:
                best_ckpt_path = osp.join(cfg.work_dir, best_ckpt_path)

第2行代码将变量best_ckpt_path初始化为None,这个变量将用于存储最佳检查点文件的路径。

 best_ckpt_path = None
 ckpt_paths = [x for x in os.listdir(cfg.work_dir) if 'best' in x]
 ckpt_paths = [x for x in ckpt_paths if x.endswith('.pth')]

第5行到第7行

这段代码执行以下操作:

  1. best_ckpt_path = None: 将变量 best_ckpt_path 初始化为 None,用于存储最佳检查点文件的路径。

  2. ckpt_paths = [x for x in os.listdir(cfg.work_dir) if 'best' in x]: 通过遍历指定目录 (cfg.work_dir) 中的文件,将包含关键词 'best' 的文件名添加到列表 ckpt_paths 中。这一步筛选出了目录中与最佳检查点相关的文件。

  3. ckpt_paths = [x for x in ckpt_paths if x.endswith('.pth')]: 继续筛选 ckpt_paths 列表,只保留文件名以 .pth 结尾的文件路径。这一步确保只有以 .pth 结尾的文件被考虑作为最佳检查点文件。

通过执行以上步骤,代码段的目的是在给定的工作目录 (cfg.work_dir) 中查找最佳检查点文件,并将其路径存储在 best_ckpt_path 变量中。如果没有符合条件的文件,best_ckpt_path 将保持为 None

            if len(ckpt_paths) == 0:
                logger.info('Warning: test_best set, but no ckpt found')
                test['test_best'] = False
                if not test['test_last']:
                    return
            elif len(ckpt_paths) > 1:
                epoch_ids = [
                    int(x.split('epoch_')[-1][:-4]) for x in ckpt_paths
                ]
                best_ckpt_path = ckpt_paths[np.argmax(epoch_ids)]
            else:
                best_ckpt_path = ckpt_paths[0]
            if best_ckpt_path:
                best_ckpt_path = osp.join(cfg.work_dir, best_ckpt_path)

这段代码根据前面获取的符合条件的最佳检查点文件路径列表 ckpt_paths 执行以下操作:

  1. 如果 ckpt_paths 的长度为0,即没有找到符合条件的最佳检查点文件:

    • 输出警告信息:logger.info('Warning: test_best set, but no ckpt found'),提示用户设置了 test_best,但未找到检查点文件。
    • 将 test['test_best'] 设置为 False,表示禁用对最佳检查点的测试。
    • 如果 test['test_last'] 也为 False,则直接返回,不执行后续代码。
  2. 如果 ckpt_paths 的长度大于1,即找到多个符合条件的最佳检查点文件:

    • 提取每个文件名中的 epoch ID(假设文件名格式为 'epoch_<ID>.pth'),并将它们转换为整数列表 epoch_ids
    • 通过 np.argmax(epoch_ids) 找到具有最大 epoch ID 的索引,然后使用该索引从 ckpt_paths 中获取最佳检查点文件的路径,并将其赋值给 best_ckpt_path
  3. 如果 ckpt_paths 的长度等于1,即只找到一个符合条件的最佳检查点文件:

    • 将 best_ckpt_path 设置为 ckpt_paths[0],即唯一找到的最佳检查点文件的路径。
  4. 如果 best_ckpt_path 不为 None,则将其与工作目录路径 (cfg.work_dir) 进行连接,得到完整的最佳检查点文件路径。

通过这些步骤,代码段的目标是确定最佳检查点文件的路径,并将其存储在 best_ckpt_path 变量中,以供后续使用。

https://github.com/kennymckormick/pyskl/blob/main/pyskl/apis/train.py

  • 28
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
This current book provides new research on artificial neural networks (ANNs). Topics discussed include the application of ANNs in chemistry and chemical engineering fields; the application of ANNs in the prediction of biodiesel fuel properties from fatty acid constituents; the use of ANNs for solar radiation estimation; the use of in silico methods to design and evaluate skin UV filters; a practical model based on the multilayer perceptron neural network (MLP) approach to predict the milling tool flank wear in a regular cut, as well as entry cut and exit cut, of a milling tool; parameter extraction of small-signal and noise models of microwave transistors based on ANNs; and the application of ANNs to deep-learning and predictive analysis in semantic TCM telemedicine systems. Chapter 1 - Today, the main effort is focused on the optimization of different processes in order to reduce and provide the optimal consumption of available and limited resources. Conventional methods such as one-variable-at-a-time approach optimize one factor at a time instead of all simultaneously. Unlike this method, artificial neural networks provide analysis of the impact of all process parameters simultaneously on the chosen responses. The architecture of each network consists of at least three layers depending on the nature of process which to be analyzed. The optimal conditions obtained after application of artificial neural networks are significantly improved compared with those obtained using conventional methods. Therefore artificial neural networks are quite common method in modeling and optimization of various processes without the full knowledge about them. For example, one study tried to optimize consumption of electricity in electric arc furnace that is known as one of the most energy-intensive processes in industry. Chemical content of scrap to be loaded and melted in the furnace was selected as the input variable while the specific electricity consumption was the output variable. Other studies modeled the extraction and adsorption processes. Many process parameters, such as extraction time, nature of solvent, solid to liquid ratio, extraction temperature, degree of disintegration of plant materials, etc. have impact on the extraction of bioactive compounds from plant materials. These parameters are commonly used as input variables, while the yields of bioactive compounds are used as output during construction of artificial neural network. During the adsorption, the amount of adsorbent and adsorbate, adsorption time, pH of medium are commonly used as the input variables, while the amount of adsorbate after treatment is selected as output variable. Based on the literature review, it can be concluded that the application of artificial neural networks will surely have an important role in the modeling and optimization of chemical processes in the future. viii Gayle Cain Chapter 2 - Problems in chemistry and chemical engineering are composed of complex systems. Various chemical processes in chemistry and chemical engineering can be described by different mathematical functions as, for example, linear, quadratic, exponential, hyperbolic et al. There are many of calculated and experimental descriptors/molecular properties to describe the chemical behavior of the substances. It is also possible that many variables can influence the desired response. Usually, chemometrics is widely used as a valuable tool to deal chemical data, and to solve complex problems. In this context, Artificial Neural Networks (ANN) is a chemometric tool that may provide accurate results for complex and non-linear problems that demand high computational costs. The main advantages of ANN techniques include learning and generalization ability of data, fault tolerance and inherent contextual information processing in addition to fast computation capacity. Due to the popularization, there is a substantial interest in ANN techniques, in special in their applications in various fields. The following types of applications are considered: data reduction using neural networks, overlapped signal resolution, experimental design and surface response, modeling, pattern recognition, and multivariate regression. Chapter 3 - Energy consumption in buildings and indoor thermal comfort nowadays issues in engineering applications. A deep analysis of these problems generally requires many resources. Many studies were carried out in order to improve the methodology available for the evaluation of the energy consumption or indoor thermal conditions; interesting solutions with a very good feedback found in the Literature are the Artificial Neural Networks (ANNs). The peculiarity of ANNs is the opportunity of simulating and resolving complex problems thanks to their architecture, which allows to identify the combination of the involved parameters even when they are in a large amount. The Artificial Neural Networks (ANNs) are very common in engineering applications for simulating the energy performance of buildings, for predicting a particular parameter, or for evaluating the indoor thermal conditions in specific environments. However, many different Artificial Neural Networks are available and each of them should be applied in a specific field. This chapter examines and describes the ANNs generally used in the engineering field. Studies of ANNs applied in topics such as energy consumption in buildings, gas emissions evaluation, indoor and outdoor thermal conditions calculation, renewable energy sources investigation, and lighting and acoustics applications are reported. After a brief description of the main characteristics of ANNs, which allows to focus on the main peculiarity and characteristics of this kind of algorithms, some applications shown in the Literature and applied to engineering issues are described. In the first part of the chapter an analysis of the main parameters which influence the ANN implementation in the examined papers was carried out, then some applications of ANN in energy and buildings field found in the Literature are described. In particular, the main studies were described considering five different clusters: in the first group the ANN applications to buildings and traditional energy plants are showed, in the second one the ANN implementation for the thermal and energy performance evaluation of renewable energy sources are reported. In the third and forth clusters the applications found in the Literature for the indoor thermal parameters investigation and outdoor thermal conditions calculation are described, while in the last one other topics investigated using ANN models such as lighting and acoustics issues are considered. Preface ix Chapter 4 - Biodiesel is generally accepted as an alternative fuel to fossil-derived diesel and has been produced from numerous oil-based biological sources. Determination of fuel properties of biodiesel has mainly being experimental which in most cases is expensive, time consuming and strenuous. These fuel properties are strongly linked to fatty acid (FA) composition of the oil used in biodiesel production. This paper presents the application of artificial neural network (ANN) in predicting selected biodiesel fuel properties (cetane number (CN), flash point (FP), kinematic viscosity (KV) and density) from the FA compositions of the oils contained in raw materials employed in biodiesel production. ANNs are nonlinear computer algorithms which are widely and successfully applied in many fields of study in simulating complex problems. Palmitic, stearic, oleic, linoleic and linolenic acids were observed to be the principal FAs in oils gathered from 58 feedstocks sourced from in literature. FAs outside the five prominent FAs were embedded into them based on their levels of saturation and unsaturation, and were used as inputs in training the networks. Neural network toolbox in MATLAB® (2013b) was employed in this study. Data of FAs and fuel properties were used in training CN, KV, FP and density networks based on back propagation algorithm. Levenberg–Marquardt algorithm, logsig (hidden layer) and purelin (out layer) were used as training algorithm and transfer functions, respectively. Different architectures (5-6-4 (CN and FP); 5-7-4 (KV); 6-5-4 (density)) were employed in training the networks due to variation in the number of neurons in both the input (temperature as additional parameter) and hidden layers. In this study, the networks achieved high accuracy for the prediction of CN, KV, FP and density with correlation coefficients of 0.962, 0.943, 0.987 and 0.985, respectively. This result indicates good agreement between the predicted results and the experimental values, and those of previous studies found in literature. Errors associated with the prediction performance of the networks were estimated using statistical methods and were found to be within satisfactory range of accuracy. Finally, this study shows that the networks via ANN modelling can be alternative methods in predicting CN, KV, FP and density from FA compositions outside the intricate and time-consuming standard test methods. Chapter 5 - The objective of this paper is show how ANN methods can be used for solar radiation estimation at short time-scale (5-min): firstly an ANN method was applied for estimating horizontal solar irradiation from other meteorological parameters more easily and frequently measured over the World and a second ANN model was developed for transforming horizontal solar irradiation into tilted irradiation. Only one thousand continental stations around the world measures solar radiation and often with a poor quality. The authors showed that 5-min solar irradiations can be estimated from more available, more readily measurable and cheaper data using Artificial Neural Networks (ANN). 7 meteorological parameters and 3 calculated parameters are used as inputs, thus 1023 combinations of inputs data are possible; the best combinations of inputs are pursued. The best ANN models have a good adequacy mainly with sunshine duration in the input set. The 6 and 10 inputs models have a relative root means square error (nRMSE) equal to 19.35% and 18.65% which is very good for such a time-step. Solar collector are rarely in horizontal position; However, solar radiation is always measured in a horizontal plane; converting measured horizontal global solar irradiance in tilted ones is a difficult task, particularly for a small time-step and for not-averaged data. Conventional methods (statistical, correlation, ...) are not always efficient with time-step less than one hour; thus, the authors want to know if an Artificial Neural Network (ANN) is able to realize this conversion with a good accuracy when applied to 5-min solar radiation data. x Gayle Cain nRMSE is around 8% for the optimal configuration, which corresponds to a very good accuracy for such a short time-step. These two successive studies show the applicability of ANN methods for the estimation of solar radiation; estimating solar radiation is particularly difficult because the sky diffuse component of solar radiation is anisotropic and the relations between parameters are rarely linear. Chapter 6 - Excessive exposure to sunlight is the major cause of progressive skin photo aging, sunburn and skin cancers. The UVB component of sunlight directly damages cellular DNA and leads to the formation of squamous cell carcinomas, while the UVA component of sunlight penetrates deeper into the skin causing DNA damage through generation of reactive oxygen species (ROS). UV filters are the active ingredients in sunscreen products, which protect skin from the dangerous effects of UV light by absorbing, reflecting, or diffusing UV radiation. In order to maintain effective UV protection, sunscreen filters should remain on the skin surface, accumulate in the stratum corneum, forming an effective barrier against UV radiation without transdermally penetrating into the systemic circulation. Further skin penetration significantly reduces their efficacy and may also cause phototoxic and photoallergic skin reactions. However, chemicals in contact with the skin have the potential to be absorbed into the skin and enter the systemic circulation, with several studies reporting that a number of organic filters significantly penetrate the skin. For assessment of dermal absorption, in vitro and in vivo methods are used, although in vitro tests are preferred for ethical reasons and feasibility. Therefore, it would be useful if the skin penetration of a sunscreen filter can be predicted from its chemical structure alone. Computational and QSAR based methods can be quite useful for development of skin permeability models and have been used to relate physicochemical parameters to dermal permeability to predict dermal penetration and absorption of chemicals. Skin penetration or partitioning like sorption processes are generally driven by hydrophobic effects, which are expected to correlate with molecular size and lipophilicity, together with the various intermolecular interactions, which occur between the permeant and the skin. Hence, this study aimed to develop a QSAR using a heterogeneous data set based on published skin penetration data and then to use this established model to predict the skin penetration of UV sunscreen filter molecules. In order to overcome the limitations associated with linear modelling, artificial neural networks (ANNs) were used to build the QSAR model. Sensitivity analysis was also incorporated into the modelling process in order to establish the molecular requirements for the ideal sunscreen filter. The developed model provides insight into the molecular structural requirements that are important for an effective UV sunscreen filter, particularly in relation to dermal absorption. Producing sunscreens with limited dermal absorption of actives is a challenge for the cosmetic industry so the developed QSAR model should prove useful in developing more effective and safer sunscreen actives. Chapter 7 - Milling cutters are important cutting tools used in milling machines to perform milling operations, which are prone to wear and subsequent failure. In this research work, a practical model based on the multilayer perceptron neural network (MLP) approach to predict the milling tool flank wear in a regular cut, as well as entry cut and exit cut, of a milling tool is proposed. Indeed, a MLP–based model was successfully used here to predict the milling tool flank wear (output variable) as a function of the following input variables: the time duration of experiment, depth of cut, feed, type of material, etc. Regression with optimal hyperparameters was performed and a correlation coefficient equal to 0.92 was obtained. To Preface xi accomplish the objective of this study, the experimental dataset represents experiments from runs on a milling machine under various operating conditions. Data sampled by three different types of sensors (acoustic emission sensor, vibration sensor and current sensor) were acquired at several positions. The MLP–based model’s goodness of fit to experimental data confirmed the good performance of this model. Finally, conclusions of this work are exposed. Chapter 8 - Microwave transistors are among the key components of circuits used in modern communication systems. In computer aided design of these circuits it is necessary to use their accurate and reliable models in order to represent them properly. There are a plenty of models developed, but still the models based on a transistor equivalent circuit representation are the most widely used and preferred by the circuit designers. The parameters of equivalent circuit models are extracted from a set of measured characteristics of a transistor to be modeled. For certain models there are analytical approaches for model parameter extraction. However, optimizations in circuit simulators are dominantly applied. Optimizations take a certain amount of time, which is especially important when repeated iterations are needed to determine the model parameters under different transistor working conditions. Artificial neural networks have appeared to be a very convenient tool to develop efficient extraction procedures of device model parameters. In this chapter a comprehensive study of the developed neural network based extraction approaches is given, considering transistor small-signal and noise models. A short introduction on the microwave transistor models and frequently used extraction procedures is given at the beginning, followed by a description of the multilayered neural networks and procedures of their training and validation. The main part of the Chapter refers to several extraction approaches based on neural networks, starting from the development of the extraction procedure, through their validation and up to the final application. The advantages and possible limitations are discussed. Appropriate numerical results are included to illustrate and verify the presented procedures. Chapter 9 - The study aims to establish a deep learning and predictive model in the semantic TCM telemedicine system using Artificial Neural Network Microsoft Azure Machine Learning. In Chinese Medicine diagnosis, four examination methods: Questioning/history taking, inspection, auscultation (listening) and olfaction (smelling), and palpation. Deep learning is an appropriate technique for the clinical decision support. The result is promising. Next step includs studying the herb-herb interaction. And when a model has been validated, it is easy to publish this as a web service with an auto-documented REST API, to be consumed by apps, and in future we deploy as SaaS and Integrative Medicine Model and using the Microsoft Azure and NVidia the state-of-the-art GPU Visualization Infrastructure and GPU Compute Infrastructure.
Introduction When I started this project, I had two requirements and I strived throughout the book to balance both of them. My first requirement comes from being an instructor and consultant for 10 years now. In that time, I have found a consistent void with most of my students and clients. It is not that clients are unwilling to implement new technologies. It is not that students are unable to learn about new technologies. The void is between those two. You learn about new technologies, but often the knowledge you gain does not provide a solid understanding of where in the network the new technology resides. You get design models, learn commands to turn features on and off, but you don’t know where to locate the device or why to implement a particular application or feature. For this reason, I have written this book in the form of a single case study that runs through the entire book. The case study revolves around a single, fictitious company that I created for the sole purpose of explaining where and why technologies should be placed in a real network. I hope that they do not become just objectives in a book for you to memo- rize. The Real World Scenarios are designed to trigger your thought process and allow you to find practical applications in your own networks. Speaking of objectives, this brings me to the second requirement for the book. That requirement is to fill a hole in having a single source of information, a place to learn about all of the common technologies used by network engineers today. To provide an outline for those common technologies, I used the objectives in place as of January 2009 for the Cisco Certified Network Professional (CCNP) certification. It would be difficult to cover every single objective from this certification track in one book, but you will find I have covered a vast majority of the objectives. My hope is that you will find this book a valuable supplemental guide in your studies as you endeavor to attain the coveted CCNP certification. The challenge was getting as many technologies into the book with enough detail so you would to know where and how to use them. There is not enough room in a single book to cover every possible solution or every single command and option you could use to accomplish a task. I do recommend some of the best and most common ways to accomplish the tasks. On that note, I hope that my coverage of wireless technologies in the last two chapters of the book will pique your interest in the exciting new technologies in wireless LANs. If you want a more in-depth fundamental look at how wireless networks operate and all of the fun, new toys (I mean wireless devices) that you can use to implement them, then watch for the new CCNA wireless book that Todd Lammle and I are currently writing for Sybex. Who Should Read This Book I highly recommend to anyone reading this book to have their CCNA certification or a firm understanding of the objectives and concepts covered. I put so many technologies into this one book, and covered as much of the CCNP material as possible that I didn’t have the space required to review all of the CCNA material. 83605book.indd 25 3/26/09 11:26:31 AM xxvi Introduction How to Use This Book This book not only covers many exciting and complex networking topics but shows you the steps required to design a full corporate internetwork. If you follow the chapters in order, I walk you not only through building single VLANs and subnets but through the security, voice, QoS, and wireless technologies you need to implement an entire campus network. How This Book Is Organized In Chapter 1, I provide for you an explanation of Cisco’s current design methodologies. This includes a discussion on Cisco’s Enterprise Composite Design Model and how that model has evolved over the years. Even a little bit about where it may go in the future. Following the design section of Chapter 1, I break down for you in detail what you can expect to accomplish in each chapter of the book and explain why I organized the book the way I did. After that, I describe for you the case study that is the framework for the book. This includes background of FutureTech, Inc., the network layout that the company has, and the technologies you are going to implement over the course of the book. You will be acting as the senior network engineer for the company (or the highly paid expert consultant that helps them through the process, if that sounds better to you). The last thing that I cover in Chapter 1 is the equipment and lab setup you can use to test and practice the technologies and topics you go through in the book. I will give you a breakdown of the topology that I will be using and supplemental equipment that can be used in exchange for the equipment that I have in my setup. With those details out of the way, I jump right into helping you build your network. Chapter 2 provides the lowdown on switching. Here you get a look at Layer 1 and Layer 2 functionality and access layer devices, creating a strong foundation from which to build the rest of the network. Then, I get into some Layer 3 functions with inter-VLAN routing. In Chapter 3, I walk you through controlling the topology and your connections. By the time you’ve finished Chapter 3 you will understand all of the functions of STP and how it prevents broadcast storms, multiple frame copies, and protects the stability of the MAC address table. In Chapters 4 through 7, you learn specifically about the routing process itself and how to give routers the information they require. I cover both static and dynamic routing protocols in depth, along with ways to filter and control the propagation of routing information between routers and routing domains. I also provide you with the means to verify and troubleshoot your network connections. Chapters 8 through 10 teach you about protocols and functions that make your net- work more reliable and efficient. In Chapter 8, I cover multicast. Here you learn what makes multicast work and see some of the configurations available to help you cope with increased use of applications and programs that send large amounts of data to a whole group of users. Continuing in this vein in Chapter 9, I give you the nuts and bolts of Inter- net Protocol version 6 (IPv6). In Chapter 10, I show you how to provide redundancy and load balancing features to your network using just your routers. You learn to configure and use HSRP, VRRP, and GLBP
给你提供了完整代码,但在运行以下代码时出现上述错误,该如何解决?Batch_size = 9 DataSet = DataSet(np.array(x_train), list(y_train)) train_size = int(len(x_train)*0.8) test_size = len(y_train) - train_size train_dataset, test_dataset = torch.utils.data.random_split(DataSet, [train_size, test_size]) TrainDataloader = Data.DataLoader(train_dataset, batch_size=Batch_size, shuffle=False, drop_last=True) TestDataloader = Data.DataLoader(test_dataset, batch_size=Batch_size, shuffle=False, drop_last=True) model = Transformer(n_encoder_inputs=3, n_decoder_inputs=3, Sequence_length=1).to(device) epochs = 10 optimizer = torch.optim.Adam(model.parameters(), lr=0.0001) criterion = torch.nn.MSELoss().to(device) val_loss = [] train_loss = [] best_best_loss = 10000000 for epoch in tqdm(range(epochs)): train_epoch_loss = [] for index, (inputs, targets) in enumerate(TrainDataloader): inputs = torch.tensor(inputs).to(device) targets = torch.tensor(targets).to(device) inputs = inputs.float() targets = targets.float() tgt_in = torch.rand((Batch_size, 1, 3)) outputs = model(inputs, tgt_in) loss = criterion(outputs.float(), targets.float()) print("loss", loss) loss.backward() optimizer.step() train_epoch_loss.append(loss.item()) train_loss.append(np.mean(train_epoch_loss)) val_epoch_loss = _test() val_loss.append(val_epoch_loss) print("epoch:", epoch, "train_epoch_loss:", train_epoch_loss, "val_epoch_loss:", val_epoch_loss) if val_epoch_loss < best_best_loss: best_best_loss = val_epoch_loss best_model = model print("best_best_loss ---------------------------", best_best_loss) torch.save(best_model.state_dict(), 'best_Transformer_trainModel.pth')
07-15

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值