Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG Report]: saving model in MacOS fails #1273

Open
thomasd3 opened this issue Oct 24, 2024 · 0 comments
Open

[BUG Report]: saving model in MacOS fails #1273

thomasd3 opened this issue Oct 24, 2024 · 0 comments

Comments

@thomasd3
Copy link

thomasd3 commented Oct 24, 2024

Description

I'm on MacOS (Intel), and saving a model causes the save function to fail as it's missing a library.

Reproduction Steps

Here is the F# port of the XOR sample code:

open Microsoft.FSharp.Collections
open Tensorflow
open Tensorflow.NumPy
type tf = KerasApi



[<EntryPoint>]
let main argv =
    let dx = array2D [| [| 0.0f; 0.0f |]; [| 0.0f; 1.0f |]; [| 1.0f; 0.0f |]; [| 1.0f; 1.0f |] |]
    let x = np.array(dx)

    let dy = array2D [| [| 0.0f |]; [| 1.0f |]; [| 1.0f |]; [| 0.0f |] |]
    let y = np.array(dy)

    let model = tf.keras.Sequential()
    model.add(tf.keras.Input(2))
    model.add(tf.keras.layers.Dense(32, tf.keras.activations.Relu))
    model.add(tf.keras.layers.Dense(1, tf.keras.activations.Sigmoid))

    model.compile(optimizer = tf.keras.optimizers.Adam(), loss = tf.keras.losses.MeanSquaredError(), metrics = [| "accuracy" |])
    model.fit(x, y, batch_size = 4, epochs = 200, use_multiprocessing = true) |> ignore
    let d = model.evaluate(x, y)
    let result = model.predict(x, 4)


    model.save_weights("test-weights.model")
    model.save("test.model")
    0

The libraries included in the project are:

    <ItemGroup>
      <PackageReference Include="SciSharp.Models.TimeSeries" Version="0.9.0" />
      <PackageReference Include="SciSharp.TensorFlow.Redist-OSX" Version="2.15.0" Condition="'$(Configuration)'!='GPU'" />
      <PackageReference Include="TensorFlow.Keras" Version="0.15.0" />
      <PackageReference Update="FSharp.Core" Version="8.0.401" />
    </ItemGroup>

Both save calls give this error:

System.TypeInitializationException: The type initializer for 'HDF.PInvoke.H5T' threw an exception.
 ---> System.TypeInitializationException: The type initializer for 'HDF.PInvoke.H5DLLImporter' threw an exception.
 ---> System.IO.FileNotFoundException: /Users/USER/*/libhdf5.dylib```

### Known Workarounds

_No response_

### Configuration and Other Information

_No response_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant