diff --git a/math/py-keras/Makefile b/math/py-keras/Makefile index f14617d74dfb..d88d2baf72c0 100644 --- a/math/py-keras/Makefile +++ b/math/py-keras/Makefile @@ -1,37 +1,42 @@ PORTNAME= keras -DISTVERSION= 3.12.0 -PORTREVISION= 1 +DISTVERSION= 3.14.0 CATEGORIES= math python # machine-learning MASTER_SITES= PYPI PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} MAINTAINER= yuri@FreeBSD.org COMMENT= Multi-backend deep learning library for Python -WWW= https://keras.io/ +WWW= https://keras.io/ \ + https://github.com/keras-team/keras LICENSE= APACHE20 BUILD_DEPENDS= ${PY_SETUPTOOLS} \ ${PYTHON_PKGNAMEPREFIX}wheel>0:devel/py-wheel@${PY_FLAVOR} -RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}numpy1>=1.16:math/py-numpy1@${PY_FLAVOR} \ +RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}numpy1>0:math/py-numpy1@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}absl-py>0:devel/py-absl-py@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}h5py>0:science/py-h5py@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}ml-dtypes>0:math/py-ml-dtypes@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}namex>0:devel/py-namex@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}optree>0:devel/py-optree@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}packaging>0:devel/py-packaging@${PY_FLAVOR} \ - ${PYTHON_PKGNAMEPREFIX}rich>0:textproc/py-rich@${PY_FLAVOR} \ - ${PYTHON_PKGNAMEPREFIX}tensorflow>=2.12.0:science/py-tensorflow@${PY_FLAVOR} -RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}scipy>=1.0:science/py-scipy@${PY_FLAVOR} + ${PYTHON_PKGNAMEPREFIX}rich>0:textproc/py-rich@${PY_FLAVOR} +RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}scipy>=1.0:science/py-scipy@${PY_FLAVOR} \ + ${PYTHON_PKGNAMEPREFIX}tensorflow>0:science/py-tensorflow@${PY_FLAVOR} # Extra dependencies for optional backends (jax, torch) # openvino backend not available as FreeBSD port EXTRA_DEPENDS= ${PYTHON_PKGNAMEPREFIX}jax>0:math/py-jax@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}pytorch>0:misc/py-pytorch@${PY_FLAVOR} USES= python -USE_PYTHON= autoplist concurrent pep517 +USE_PYTHON= pep517 concurrent autoplist NO_ARCH= yes +TEST_ENV= ${MAKE_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR} + +test-simple: + ${SETENV} ${TEST_ENV} ${PYTHON_CMD} ${FILESDIR}/test-simple-1.py + .include diff --git a/math/py-keras/distinfo b/math/py-keras/distinfo index 71f79dad70e0..82113b540b66 100644 --- a/math/py-keras/distinfo +++ b/math/py-keras/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1730473740 -SHA256 (keras-3.12.0.tar.gz) = 536e3f8385a05ae04e82e08715a1a59988578087e187b04cb0a6fad11743f07f -SIZE (keras-3.12.0.tar.gz) = 1129187 +TIMESTAMP = 1775491282 +SHA256 (keras-3.14.0.tar.gz) = 86fcf8249a25264a566ac393c287c7ad657000e5e62615dcaad4b3472a17aeda +SIZE (keras-3.14.0.tar.gz) = 1263098 diff --git a/math/py-keras/files/patch-pyproject.toml b/math/py-keras/files/patch-pyproject.toml index 16e73477ceb8..66dceeb8110c 100644 --- a/math/py-keras/files/patch-pyproject.toml +++ b/math/py-keras/files/patch-pyproject.toml @@ -1,20 +1,20 @@ --- pyproject.toml.orig 2025-11-01 14:52:19 UTC +++ pyproject.toml @@ -11,7 +11,7 @@ license = {text = "Apache License 2.0"} readme = "README.md" requires-python = ">=3.10" license = {text = "Apache License 2.0"} -dynamic = ["version"] -+version = "3.12.0" ++version = "3.14.0" classifiers = [ "Development Status :: 4 - Beta", "Programming Language :: Python :: 3", @@ -40,8 +40,6 @@ Repository = "https://github.com/keras-team/keras" Home = "https://keras.io/" Repository = "https://github.com/keras-team/keras" -[tool.setuptools.dynamic] -version = {attr = "keras.src.version.__version__"} [tool.setuptools.package-dir] "" = "." diff --git a/math/py-keras/files/test-simple-1.py b/math/py-keras/files/test-simple-1.py new file mode 100644 index 000000000000..2f273a263e7c --- /dev/null +++ b/math/py-keras/files/test-simple-1.py @@ -0,0 +1,40 @@ +from keras.models import Sequential +from keras.layers import Dense +import numpy as np + +# 1. Generate dummy data (replace with your actual data) +# For binary classification, let's create a simple dataset +X = np.random.rand(100, 5) # 100 samples, 5 features +y = (X.sum(axis=1) > 2.5).astype(int) # Binary labels based on feature sum + +# 2. Define the Keras Sequential model +model = Sequential() + +# Add a Dense (fully connected) hidden layer +# 12 nodes, 'relu' activation, input_shape specifies the number of features in your input +model.add(Dense(12, input_shape=(5,), activation='relu')) + +# Add another Dense hidden layer +model.add(Dense(8, activation='relu')) + +# Add the output layer +# 1 node for binary classification, 'sigmoid' activation for probabilities +model.add(Dense(1, activation='sigmoid')) + +# 3. Compile the Keras model +# 'adam' optimizer is a good general-purpose optimizer +# 'binary_crossentropy' is suitable for binary classification +# 'accuracy' is a common metric to monitor during training +model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy']) + +# 4. Train the model +# epochs: number of times to iterate over the entire dataset +# batch_size: number of samples per gradient update +model.fit(X, y, epochs=50, batch_size=32, verbose=0) # verbose=0 suppresses training output + +# 5. Evaluate the model (optional) +loss, accuracy = model.evaluate(X, y, verbose=0) +print(f"Model Loss: {loss:.4f}, Accuracy: {accuracy:.4f}") + +# 6. Make predictions (optional) +predictions = model.predict(X) diff --git a/math/py-keras/pkg-descr b/math/py-keras/pkg-descr index 6a2f8f1c0594..41e0b7ca519b 100644 --- a/math/py-keras/pkg-descr +++ b/math/py-keras/pkg-descr @@ -1,2 +1,7 @@ -Deep Learning library for Python. Convnets, recurrent neural networks, and -more. Runs on Theano, TensorFlow, JAX, OpenVino. +Keras is a high-level, multi-backend deep learning API that allows you +to run the same code on JAX, PyTorch, or TensorFlow. + +It is designed for human beings, not machines. Keras follows best +practices for reducing cognitive load: it offers consistent & simple +APIs, it minimizes the number of user actions required for common use +cases, and it provides clear & actionable error messages.