《Alleviating Matthew Effect of Offline Reinforcement Learningin Interactive Recommendation》笔记4.0(1)

##部分截图(草稿,后续会删除)

args的各个参数值

# %% 3. Setup model

def get_task(envname, yfeat):

def setup_world_model

二、代码阅读

2.1.4设置世界模型(第三步)

task, task_logit_dim, is_ranking = get_task(args.env, args.yfeat)

获得了

ensemble_models = setup_world_model(args, x_columns, y_columns, ab_columns,
                                    task, task_logit_dim, is_ranking, MODEL_SAVE_PATH)

获得的 ensemble_models 是一堆路径和模型

对 user_model 的解释

以user_model的第一行为例,

她所代表的含义是

初始是通过传递参数以创建一个EnsembleModel对象获得的

接着获取损失函数

这里选择的是负点对损失函数,其构成如下:

解释如下

y_weighted, loss_ab = process_logit(y_deepfm_pos, score, alpha_u=alpha_u, beta_i=beta_i, args=args)

的处理过程如下

此处对应了论文中的公式(10)

损失函数的输入:

y: 对应函数参数y,表示真实的目标值。
y_deepfm_pos: 对应函数参数y_deepfm_pos,表示DeepFM模型预测的正样本预测值。
y_deepfm_neg: 对应函数参数y_deepfm_neg,表示DeepFM模型预测的负样本预测值。
score: 对应函数参数score,表示用于计算损失函数的得分或权重。
alpha_u: 对应函数参数alpha_u,表示用于计算损失函数的用户相关参数。
beta_i: 对应函数参数beta_i,表示用于计算损失函数的物品相关参数。
args: 对应函数参数args,表示传递给损失函数的配置参数。

损失函数的输出:

总损失loss。

接着对  ensemble_models  进行编译

具体来说  compile() 方法会对每个模型(共5个)进行编译,编译的步骤如下:

以第一个模型的编译结果为例

ensemble_models的user_model的第一个模型中,loss_func的值为

functools.partial(<function loss_pointwise_negative at 0x0000019FE49D1E10>, args=Namespace(env='KuaiEnv-v0', resume=False, optimizer='adam', seed=2022, bpr_weight=0.5, neg_K=3, n_models=5, is_softmax=False, num_trajectory=200, force_length=10, top_rate=0.8, deterministic=True, draw_bar=False, is_all_item_ranking=False, loss='pointneg', rankingK=(20, 10, 5), max_turn=30, l2_reg_dnn=0.1, lambda_ab=10, epsilon=0, is_ucb=False, dnn_activation='relu', feature_dim=8, entity_dim=8, user_model_name='DeepFM', dnn=(128, 128), dnn_var=(), batch_size=4096, epoch=5, cuda=0, tau=0, is_ab=False, message='pointneg', all_item_ranking=False, leave_threshold=0, num_leave_compute=10, is_userinfo=False, is_binarize=False, need_transform=True, entropy_window=[1, 2], yfeat='watch_ratio_normed', use_userEmbedding=False))

也就是说,第一个模型的loss_func是一个经过部分应用的损失函数,其中的参数通过args对象进行绑定。ensemble_models的每一个模型均有一个loss_func

其中,loss_func的keywords中的‘args’具体为

表示的含义为

全部编译好后返回  ensemble_models

继续获取真实环境env,环境任务类env_task_class(未返回)和关键字参数字典kwargs_um

env:

kwargs_um

接着根据环境名称获取训练中的物品主导信息

从上至下,所示类别占据主导地位的强度逐渐下降,也就是说,类别28的主导性最强。也可以理解为,用户观看类别28的视频对最有利于获得更好的结果(比如对应的观看时长更长等)。

最后,再次编译  ensemble_models  (利用.compile_RL_test()方法)为其设置评估函数

ensemble_models.compile_RL_test(
    functools.partial(test_static_model_in_RL_env, env=env, dataset_val=dataset_val, is_softmax=args.is_softmax,
                      epsilon=args.epsilon, is_ucb=args.is_ucb, need_transform=args.need_transform,
                      num_trajectory=args.num_trajectory, item_feat_domination=item_feat_domination,
                      force_length=args.force_length, top_rate=args.top_rate))

循环编译5个模型

对于第一个模型


test_static_model_in_RL_env所在位置如下:

处理好后,第三步完成

user_models的第一行如下:

2.1.5学习并评估模型(第五步)

history_list = ensemble_models.fit_data(dataset_train, dataset_val,
                                        batch_size=args.batch_size, epochs=args.epoch, shuffle=True,
                                        callbacks=[LoggerCallback_Update(logger_path)])

对.fit_data方法的描述

此处因突然开始训练并报错:BufferError: memoryview has 1 exported buffer,工作暂时中断。

结束

  • 17
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Chapter 1 Materials: Structure, Properties, and Performance 1 1.1 Introduction 1 1.2 Monolithic, Composite, and Hierarchical Materials 3 1.3 Structure of Materials 15 1.3.1 Crystal Structures 16 1.3.2 Metals 19 1.3.3 Ceramics 25 1.3.4 Glasses 30 1.3.5 Polymers 31 1.3.6 Liquid Crystals 39 1.3.7 Biological Materials and Biomaterials 40 1.3.8 Porous and Cellular Materials 44 1.3.9 Nano- and Microstructure of Biological Materials 45 1.3.10 The Sponge Spicule: An Example of a Biological Material 56 1.3.11 Active (or Smart) Materials 57 1.3.12 Electronic Materials 58 1.3.13 Nanotechnology 60 1.4 Strength of Real Materials 61 Suggested Reading 64 Exercises 65 Chapter 2 Elasticity and Viscoelasticity 71 2.1 Introduction 71 2.2 Longitudinal Stress and Strain 72 2.3 Strain Energy (or Deformation Energy) Density 77 2.4 Shear Stress and Strain 80 2.5 Poisson’s Ratio 83 2.6 More Complex States of Stress 85 2.7 Graphical Solution of a Biaxial State of Stress: the Mohr Circle 89 2.8 Pure Shear: Relationship between G and E 95 2.9 Anisotropic Effects 96 2.10 Elastic Properties of Polycrystals 107 2.11 Elastic Properties of Materials 110 2.11.1 Elastic Properties of Metals 111 2.11.2 Elastic Properties of Ceramics 111 2.11.3 Elastic Properties of Polymers 116 2.11.4 Elastic Constants of Unidirectional Fiber Reinforced Composite 117 2.12 Viscoelasticity 120 2.12.1 Storage and Loss Moduli 124 2.13 Rubber Elasticity 126 2.14 Mooney--Rivlin Equation 131 2.15 Elastic Properties of Biological Materials 134 2.15.1 Blood Vessels 134 2.15.2 Articular Cartilage 137 2.15.3 Mechanical Properties at the Nanometer Level 140 2.16 Elastic Properties of Electronic Materials 143 2.17 Elastic Constants and Bonding 145 Suggested Reading 155 Exercises 155 Chapter 3 Plasticity 161 3.1 Introduction 161 3.2 Plastic Deformation in Tension 163 3.2.1 Tensile Curve Parameters 171 3.2.2 Necking 172 3.2.3 Strain Rate Effects 176 3.3 Plastic Deformation in Compression Testing 183 3.4 The Bauschunger Effect 187 3.5 Plastic Deformation of Polymers 188 3.5.1 Stress--Strain Curves 188 3.5.2 Glassy Polymers 189 3.5.3 Semicrystalline Polymers 190 3.5.4 Viscous Flow 191 3.5.5 Adiabatic Heating 192 3.6 Plastic Deformation of Glasses 193 3.6.1 Microscopic Deformation Mechanism 195 3.6.2 Temperature Dependence and Viscosity 197 3.7 Flow, Yield, and Failure Criteria 199 3.7.1 Maximum-Stress Criterion (Rankine) 200 3.7.2 Maximum-Shear-Stress Criterion (Tresca) 200 3.7.3 Maximum-Distortion-Energy Criterion (von Mises) 201 3.7.4 Graphical Representation and Experimental Verification of Rankine, Tresca, and von Mises Criteria 201 3.7.5 Failure Criteria for Brittle Materials 205 3.7.6 Yield Criteria for Ductile Polymers 209 3.7.7 Failure Criteria for Composite Materials 211 3.7.8 Yield and Failure Criteria for Other Anisotropic Materials 213 3.8 Hardness 214 3.8.1 Macroindentation Tests 216 3.8.2 Microindentation Tests 221 3.8.3 Nanoindentation 225 3.9 Formability: Important Parameters 229 3.9.1 Plastic Anisotropy 231 3.9.2 Punch--Stretch Tests and Forming-Limit Curves (or Keeler--Goodwin Diagrams) 232 3.10 Muscle Force 237 3.11 Mechanical Properties of Some Biological Materials 241 Suggested Reading 245 Exercises 246 Chapter 4 Imperfections: Point and Line Defects 251 4.1 Introduction 251 4.2 Theoretical Shear Strength 252 4.3 Atomic or Electronic Point Defects 254 4.3.1 Equilibrium Concentration of Point Defects 256 4.3.2 Production of Point Defects 259 4.3.3 Effect of Point Defects on Mechanical Properties 260 4.3.4 Radiation Damage 261 4.3.5 Ion Implantation 265 4.4 Line Defects 266 4.4.1 Experimental Observation of Dislocations 270 4.4.2 Behavior of Dislocations 273 4.4.3 Stress Field Around Dislocations 275 4.4.4 Energy of Dislocations 278 4.4.5 Force Required to Bow a Dislocation 282 4.4.6 Dislocations in Various Structures 284 4.4.7 Dislocations in Ceramics 293 4.4.8 Sources of Dislocations 298 4.4.9 Dislocation Pileups 302 4.4.10 Intersection of Dislocations 304 4.4.11 Deformation Produced by Motion of Dislocations (Orowan’s Equation) 306 4.4.12 The Peierls--Nabarro Stress 309 4.4.13 The Movement of Dislocations: Temperature and Strain Rate Effects 310 4.4.14 Dislocations in Electronic Materials 313 Suggested Reading 316 Exercises 317 Chapter 5 Imperfections: Interfacial and Volumetric Defects 321 5.1 Introduction 321 5.2 Grain Boundaries 321 5.2.1 Tilt and Twist Boundaries 326 5.2.2 Energy of a Grain Boundary 328 5.2.3 Variation of Grain-Boundary Energy with Misorientation 330 5.2.4 Coincidence Site Lattice (CSL) Boundaries 332 5.2.5 Grain-Boundary Triple Junctions 334 5.2.6 Grain-Boundary Dislocations and Ledges 334 5.2.7 Grain Boundaries as a Packing of Polyhedral Units 336 5.3 Twinning and Twin Boundaries 336 5.3.1 Crystallography and Morphology 337 5.3.2 Mechanical Effects 341 5.4 Grain Boundaries in Plastic Deformation (Grain-size Strengthening) 345 5.4.1 Hall--Petch Theory 348 5.4.2 Cottrell’s Theory 349 5.4.3 Li’s Theory 350 5.4.4 Meyers--Ashworth Theory 351 5.5 Other Internal Obstacles 353 5.6 Nanocrystalline Materials 355 5.7 Volumetric or Tridimensional Defects 358 5.8 Imperfections in Polymers 361 Suggested Reading 364 Exercises 364 Chapter 6 Geometry of Deformation and Work-Hardening 369 6.1 Introduction 369 6.2 Geometry of Deformation 373 6.2.1 Stereographic Projections 373 6.2.2 Stress Required for Slip 374 6.2.3 Shear Deformation 380 6.2.4 Slip in Systems and Work-Hardening 381 6.2.5 Independent Slip Systems in Polycrystals 384 6.3 Work-Hardening in Polycrystals 384 6.3.1 Taylor’s Theory 386 6.3.2 Seeger’s Theory 388 6.3.3 Kuhlmann--Wilsdorf’s Theory 388 6.4 Softening Mechanisms 392 6.5 Texture Strengthening 395 Suggested Reading 399 Exercises 399 Chapter 7 Fracture: Macroscopic Aspects 404 7.1 Introduction 404 7.2 Theorectical Tensile Strength 406 7.3 Stress Concentration and Griffith Criterion of Fracture 409 7.3.1 Stress Concentrations 409 7.3.2 Stress Concentration Factor 409 7.4 Griffith Criterion 416 7.5 Crack Propagation with Plasticity 419 7.6 Linear Elastic Fracture Mechanics 421 7.6.1 Fracture Toughness 422 7.6.2 Hypotheses of LEFM 423 7.6.3 Crack-Tip Separation Modes 423 7.6.4 Stress Field in an Isotropic Material in the Vicinity of a Crack Tip 424 7.6.5 Details of the Crack-Tip Stress Field in Mode I 425 7.6.6 Plastic-Zone Size Correction 428 7.6.7 Variation in Fracture Toughness with Thickness 431 7.7 Fracture Toughness Parameters 434 7.7.1 Crack Extension Force G 434 7.7.2 Crack Opening Displacement 437 7.7.3 J Integral 440 7.7.4 R Curve 443 7.7.5 Relationships among Different Fracture Toughness Parameters 444 7.8 Importance of K I c in Practice 445 7.9 Post-Yield Fracture Mechanics 448 7.10 Statistical Analysis of Failure Strength 449 Appendix: Stress Singularity at Crack Tip 458 Suggested Reading 460 Exercises 460 Chapter 8 Fracture: Microscopic Aspects 466 8.1 Introduction 466 8.2 Facture in Metals 468 8.2.1 Crack Nucleation 468 8.2.2 Ductile Fracture 469 8.2.3 Brittle, or Cleavage, Fracture 480 8.3 Facture in Ceramics 487 8.3.1 Microstructural Aspects 487 8.3.2 Effect of Grain Size on Strength of Ceramics 494 8.3.3 Fracture of Ceramics in Tension 496 8.3.4 Fracture in Ceramics Under Compression 499 8.3.5 Thermally Induced Fracture in Ceramics 504 8.4 Fracture in Polymers 507 8.4.1 Brittle Fracture 507 8.4.2 Crazing and Shear Yielding 508 8.4.3 Fracture in Semicrystalline and Crystalline Polymers 512 8.4.4 Toughness of Polymers 513 8.5 Fracture and Toughness of Biological Materials 517 8.6 Facture Mechanism Maps 521 Suggested Reading 521 Exercises 521 Chapter 9 Fracture Testing 525 9.1 Introduction 525 9.2 Impact Testing 525 9.2.1 Charpy Impact Test 526 9.2.2 Drop-Weight Test 529 9.2.3 Instrumented Charpy Impact Test 531 9.3 Plane-Strain Fracture Toughness Test 532 9.4 Crack Opening Displacement Testing 537 9.5 J-Integral Testing 538 9.6 Flexure Test 540 9.6.1 Three-Point Bend Test 541 9.6.2 Four-Point Bending 542 9.6.3 Interlaminar Shear Strength Test 543 9.7 Fracture Toughness Testing of Brittle Materials 545 9.7.1 Chevron Notch Test 547 9.7.2 Indentation Methods for Determining Toughness 549 9.8 Adhesion of Thin Films to Substrates 552 Suggested Reading 553 Exercises 553 Chapter 10 Solid Solution, Precipitation, and Dispersion Strengthening 558 10.1 Introduction 558 10.2 Solid-Solution Strengthening 559 10.2.1 Elastic Interaction 560 10.2.2 Other Interactions 564 10.3 Mechanical Effects Associated with Solid Solutions 564 10.3.1 Well-Defined Yield Point in the Stress--Strain Curves 565 10.3.2 Plateau in the Stress--Strain Curve and L¨uders Band 566 10.3.3 Strain Aging 567 10.3.4 Serrated Stress--Strain Curve 568 10.3.5 Snoek Effect 569 10.3.6 Blue Brittleness 570 10.4 Precipitation- and Dispersion-Hardening 571 10.5 Dislocation--Precipitate Interaction 579 10.6 Precipitation in Microalloyed Steels 585 10.7 Dual-Phase Steels 590 Suggested Reading 590 Exercises 591 Chapter 11 Martensitic Transformation 594 11.1 Introduction 594 11.2 Structures and Morphologies of Martensite 594 11.3 Strength of Martensite 600 11.4 Mechanical Effects 603 11.5 Shape-Memory Effect 608 11.5.1 Shape-Memory Effect in Polymers 614 11.6 Martensitic Transformation in Ceramics 614 Suggested Reading 618 Exercises 619 Chapter 12 Special Materials: Intermetallics and Foams 621 12.1 Introduction 621 12.2 Silicides 621 12.3 Ordered Intermetallics 622 12.3.1 Dislocation Structures in Ordered Intermetallics 624 12.3.2 Effect of Ordering on Mechanical Properties 628 12.3.3 Ductility of Intermetallics 634 12.4 Cellular Materials 639 12.4.1 Structure 639 12.4.2 Modeling of the Mechanical Response 639 12.4.3 Comparison of Predictions and Experimental Results 645 12.4.4 Syntactic Foam 645 12.4.5 Plastic Behavior of Porous Materials 646 Suggested Reading 650 Exercises 650 Chapter 13 Creep and Superplasticity 653 13.1 Introduction 653 13.2 Correlation and Extrapolation Methods 659 13.3 Fundamental Mechanisms Responsible for Creep 665 13.4 Diffusion Creep 666 13.5 Dislocation (or Power Law) Creep 670 13.6 Dislocation Glide 673 13.7 Grain-Boundary Sliding 675 13.8 Deformation-Mechanism (Weertman--Ashby) Maps 676 13.9 Creep-Induced Fracture 678 13.10 Heat-Resistant Materials 681 13.11 Creep in Polymers 688 13.12 Diffusion-Related Phenomena in Electronic Materials 695 13.13 Superplasticity 697 Suggested Reading 705 Exercises 705 Chapter 14 Fatigue 713 14.1 Introduction 713 14.2 Fatigue Parameters and S--N (W¨ohler) Curves 714 14.3 Fatigue Strength or Fatigue Life 716 14.4 Effect of Mean Stress on Fatigue Life 719 14.5 Effect of Frequency 721 14.6 Cumulative Damage and Life Exhaustion 721 14.7 Mechanisms of Fatigue 725 14.7.1 Fatigue Crack Nucleation 725 14.7.2 Fatigue Crack Propagation 730 14.8 Linear Elastic Fracture Mechanics Applied to Fatigue 735 14.8.1 Fatigue of Biomaterials 744 14.9 Hysteretic Heating in Fatigue 746 14.10 Environmental Effects in Fatigue 748 14.11 Fatigue Crack Closure 748 14.12 The Two-Parameter Approach 749 14.13 The Short-Crack Problem in Fatigue 750 14.14 Fatigue Testing 751 14.14.1 Conventional Fatigue Tests 751 14.14.2 Rotating Bending Machine 751 14.14.3 Statistical Analysis of S--N Curves 753 14.14.4 Nonconventional Fatigue Testing 753 14.14.5 Servohydraulic Machines 755 14.14.6 Low-Cycle Fatigue Tests 756 14.14.7 Fatigue Crack Propagation Testing 757 Suggested Reading 758 Exercises 759 Chapter 15 Composite Materials 765 15.1 Introduction 765 15.2 Types of Composites 765 15.3 Important Reinforcements and Matrix Materials 767 15.3.1 Microstructural Aspects and Importance of the Matrix 769 15.4 Interfaces in Composites 770 15.4.1 Crystallographic Nature of the Fiber--Matrix Interface 771 15.4.2 Interfacial Bonding in Composites 772 15.4.3 Interfacial Interactions 773 15.5 Properties of Composites 774 15.5.1 Density and Heat Capacity 775 15.5.2 Elastic Moduli 775 15.5.3 Strength 780 15.5.4 Anisotropic Nature of Fiber Reinforced Composites 783 15.5.5 Aging Response of Matrix in MMCs 785 15.5.6 Toughness 785 15.6 Load Transfer from Matrix to Fiber 788 15.6.1 Fiber and Matrix Elastic 789 15.6.2 Fiber Elastic and Matrix Plastic 792 15.7 Fracture in Composites 794 15.7.1 Single and Multiple Fracture 795 15.7.2 Failure Modes in Composites 796 15.8 Some Fundamental Characteristics of Composites 799 15.8.1 Heterogeneity 799 15.8.2 Anisotropy 799 15.8.3 Shear Coupling 801 15.8.4 Statistical Variation in Strength 802 15.9 Functionally Graded Materials 803 15.10 Applications 803 15.10.1 Aerospace Applications 803 15.10.2 Nonaerospace Applications 804 15.11 Laminated Composites 806 Suggested Reading 809 Exercises 810 Chapter 16 Environmental Effects 815 16.1 Introduction 815 16.2 Electrochemical Nature of Corrosion in Metals 815 16.2.1 Galvanic Corrosion 816 16.2.2 Uniform Corrosion 817 16.2.3 Crevice corrosion 817 16.2.4 Pitting Corrosion 818 16.2.5 Intergranular Corrosion 818 16.2.6 Selective leaching 819 16.2.7 Erosion-Corrosion 819 16.2.8 Radiation Damage 819 16.2.9 Stress Corrosion 819 16.3 Oxidation of metals 819 16.4 Environmentally Assisted Fracture in Metals 820 16.4.1 Stress Corrosion Cracking (SCC) 820 16.4.2 Hydrogen Damage in Metals 824 16.4.3 Liquid and Solid Metal Embrittlement 830 16.5 Environmental Effects in Polymers 831 16.5.1 Chemical or Solvent Attack 832 16.5.2 Swelling 832 16.5.3 Oxidation 833 16.5.4 Radiation Damage 834 16.5.5 Environmental Crazing 835 16.5.6 Alleviating the Environmental Damage in Polymers 836 16.6 Environmental Effects in Ceramics 836 16.6.1 Oxidation of Ceramics 839 Suggested Reading 840 Exercises 840 Appendixes 843 Index 851

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值