0.1.55
This commit is contained in:
		| @@ -1,7 +1,7 @@ | |||||||
| [metadata] | [metadata] | ||||||
| # replace with your username: | # replace with your username: | ||||||
| name = guan | name = guan | ||||||
| version = 0.1.54 | version = 0.1.55 | ||||||
| author = guanjihuan | author = guanjihuan | ||||||
| author_email = guanjihuan@163.com | author_email = guanjihuan@163.com | ||||||
| description = An open source python package | description = An open source python package | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| Metadata-Version: 2.1 | Metadata-Version: 2.1 | ||||||
| Name: guan | Name: guan | ||||||
| Version: 0.1.54 | Version: 0.1.55 | ||||||
| Summary: An open source python package | Summary: An open source python package | ||||||
| Home-page: https://py.guanjihuan.com | Home-page: https://py.guanjihuan.com | ||||||
| Author: guanjihuan | Author: guanjihuan | ||||||
|   | |||||||
| @@ -1,10 +1,12 @@ | |||||||
| # Module: machine_learning | # Module: machine_learning | ||||||
| import guan | import guan | ||||||
|  | model_class = None  # 把类定义成全局的,防止保存完整模型时,无法访问函数中的类 | ||||||
|  |  | ||||||
| # 全连接神经网络模型(包含一个隐藏层) | # 全连接神经网络模型(包含一个隐藏层) | ||||||
| @guan.function_decorator | @guan.function_decorator | ||||||
| def fully_connected_neural_network_with_one_hidden_layer(input_size=1, hidden_size=10, output_size=1, activation='relu'): | def fully_connected_neural_network_with_one_hidden_layer(input_size=1, hidden_size=10, output_size=1, activation='relu'): | ||||||
|     import torch |     import torch | ||||||
|  |     global model_class | ||||||
|     class model_class(torch.nn.Module): |     class model_class(torch.nn.Module): | ||||||
|         def __init__(self): |         def __init__(self): | ||||||
|             super().__init__() |             super().__init__() | ||||||
| @@ -30,6 +32,7 @@ def fully_connected_neural_network_with_one_hidden_layer(input_size=1, hidden_si | |||||||
| @guan.function_decorator | @guan.function_decorator | ||||||
| def fully_connected_neural_network_with_two_hidden_layers(input_size=1, hidden_size_1=10, hidden_size_2=10, output_size=1, activation_1='relu', activation_2='relu'): | def fully_connected_neural_network_with_two_hidden_layers(input_size=1, hidden_size_1=10, hidden_size_2=10, output_size=1, activation_1='relu', activation_2='relu'): | ||||||
|     import torch |     import torch | ||||||
|  |     global model_class | ||||||
|     class model_class(torch.nn.Module): |     class model_class(torch.nn.Module): | ||||||
|         def __init__(self): |         def __init__(self): | ||||||
|             super().__init__() |             super().__init__() | ||||||
| @@ -68,6 +71,7 @@ def fully_connected_neural_network_with_two_hidden_layers(input_size=1, hidden_s | |||||||
| @guan.function_decorator | @guan.function_decorator | ||||||
| def fully_connected_neural_network_with_three_hidden_layers(input_size=1, hidden_size_1=10, hidden_size_2=10, hidden_size_3=10, output_size=1, activation_1='relu', activation_2='relu', activation_3='relu'): | def fully_connected_neural_network_with_three_hidden_layers(input_size=1, hidden_size_1=10, hidden_size_2=10, hidden_size_3=10, output_size=1, activation_1='relu', activation_2='relu', activation_3='relu'): | ||||||
|     import torch |     import torch | ||||||
|  |     global model_class | ||||||
|     class model_class(torch.nn.Module): |     class model_class(torch.nn.Module): | ||||||
|         def __init__(self): |         def __init__(self): | ||||||
|             super().__init__() |             super().__init__() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user