Skip to content

Commit 9cc4cc2

Browse files
v0.2.45
cleanup
1 parent 0c6dbea commit 9cc4cc2

5 files changed

Lines changed: 35 additions & 16 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "spotPython"
10-
version = "0.2.45"
10+
version = "0.2.46"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotPython/light/csvmodel.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,6 @@ def __init__(
2828
self.valid_mapk = MAPK(k=3)
2929
self.test_mapk = MAPK(k=3)
3030

31-
# self.model = nn.Sequential(
32-
# nn.Flatten(),
33-
# nn.Linear(_L_in, l1),
34-
# nn.ReLU(),
35-
# nn.Dropout(0.1),
36-
# nn.Linear(l1, l1),
37-
# nn.ReLU(),
38-
# nn.Dropout(0.1),
39-
# nn.Linear(l1, _L_out),
40-
# )
41-
4231
# Create the network based on the specified hidden sizes
4332
layers = []
4433
layer_sizes = [_L_in] + hidden_sizes

src/spotPython/light/hyperlight.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def fun(self, X, fun_control=None):
7070
try:
7171
df_eval = train_model(config, self.fun_control)
7272
except Exception as err:
73-
print(f"Error in fun_light(). Call to train_model failed. {err=}, {type(err)=}")
73+
print(f"Error in fun(). Call to train_model failed. {err=}, {type(err)=}")
7474
print("Setting df_eval to np.nan")
7575
df_eval = np.nan
7676
z_val = fun_control["weights"] * df_eval

src/spotPython/utils/device.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
def getDevice(device=None):
55
"""Get cpu, gpu or mps device for training.
66
Args:
7-
device (str): Device for training. If None,
8-
the device is selected automatically.
7+
device (str): Device for training. If None or "auto" the device is selected automatically.
98
Returns:
109
device (str): Device for training.
1110
Example:
1211
>>> from spotPython.utils.device import getDevice
1312
>>> getDevice()
1413
'cuda:0'
1514
"""
16-
if device is None:
15+
if device is None or device == "auto":
1716
device = "cpu"
1817
if torch.cuda.is_available():
1918
device = "cuda:0"

src/spotPython/utils/file.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,43 @@
11
import torchvision
22
import torchvision.transforms as transforms
3+
import socket
4+
from datetime import datetime
5+
from dateutil.tz import tzlocal
36

47

58
def load_data(data_dir="./data"):
9+
"""Loads the CIFAR10 dataset.
10+
Args:
11+
data_dir (str, optional): Directory to save the data. Defaults to "./data".
12+
Returns:
13+
trainset (torchvision.datasets.CIFAR10): Training dataset.
14+
Examples:
15+
>>> from spotPython.utils.file import load_data
16+
>>> trainset = load_data(data_dir="./data")
17+
18+
"""
619
transform = transforms.Compose([transforms.ToTensor(), transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])
720

821
trainset = torchvision.datasets.CIFAR10(root=data_dir, train=True, download=True, transform=transform)
922

1023
testset = torchvision.datasets.CIFAR10(root=data_dir, train=False, download=True, transform=transform)
1124

1225
return trainset, testset
26+
27+
28+
def get_experiment_name(prefix: str = "00") -> str:
29+
"""Returns a unique experiment name with a given prefix.
30+
Args:
31+
prefix (str, optional): Prefix for the experiment name. Defaults to "00".
32+
Returns:
33+
str: Unique experiment name.
34+
Examples:
35+
>>> from spotPython.utils.file import get_experiment_name
36+
>>> get_experiment_name(prefix="00")
37+
00_ubuntu_2021-08-31_14-30-00
38+
"""
39+
start_time = datetime.now(tzlocal())
40+
HOSTNAME = socket.gethostname().split(".")[0]
41+
experiment_name = prefix + "_" + HOSTNAME + "_" + str(start_time).split(".", 1)[0].replace(" ", "_")
42+
experiment_name = experiment_name.replace(":", "-")
43+
return experiment_name

0 commit comments

Comments
 (0)